このコードの目的は、構成データを分離することです。$config
example.php で配列を直接使用すると、すべて正常に動作します。ただし、以下のコードでは、異なる値が得られます。
facebook.php
<?php
class Facebook extends AppController{
public function __construct() {
$config = array();
$config['appId'] = '400xxx6'; //YOUR_APP_ID
$config['secret'] = 'f70f01e76xxx7e'; //YOUR_APP_SECRET
$config['cookie'] = false;
return $config;
}
}
?>
example.php
<?php
App::import('Config', 'Facebook');
$a = new Facebook();
var_dump($a);
?>
なぜ$var_dump($a);
このようなものを返すのですか?
object(Facebook)[50]
protected 'appId' => null
protected 'apiSecret' => null
protected 'user' => null
protected 'signedRequest' => null
protected 'state' => string 'e4ac55f1xxx87a88' (length=32)
protected 'accessToken' => null
protected 'fileUploadSupport' => boolean false
私が欲しいのは元の配列です。間違いは何ですか?
array
'appId' => string '400xxx6' (length=15)
'secret' => string 'f70f01e76xxx7e' (length=32)
'cookie' => boolean false