开发者

Facebook PHP API constructor - is local variable ignored for a reason?

Caveat : I a开发者_如何转开发m not a PHP guru by any stretch - hopefully someone can explain what this code is doing - why is he applying something to a local variable ($state) and then ignoring it? This code is in the 3.1.1 php sdk and I noticed it when debugging an issue with js sdk and php interactions during an authResponse trigger.

  public function __construct($config) {
    $this->setAppId($config['appId']);
    $this->setApiSecret($config['secret']);
    if (isset($config['fileUpload'])) {
      $this->setFileUploadSupport($config['fileUpload']);
    }

    $state = $this->getPersistentData('state');
    if (!empty($state)) {
      $this->state = $this->getPersistentData('state');
    }
  }

Is it as simple as he meant to use $this->state = $state?


It isn't being ignored. On the next line, it's used as a parameter for empty.

Parameters to empty must be variables (see manual), which is why it's being used like that.

However, they could probably have used it in the $this->state assignment as well. Why they didn't I wouldn't know.


It's an oversight on the programmers side I think. He could and should have assigned $state to $this->state.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜