I have a problem, which seems to be in line $this->pd_db = object(
Parse e开发者_如何学Pythonrror: syntax error, unexpected T_DOUBLE_ARROW in /var/www/website/includes/PD.php on line 10 `
Here is my code
$this->pd_db = object(
'cstm' => object(
'table_name' => "customdata",
'table_version' => '1.0'
)
);
Please solve this.
I suspect that it should look like :
$this->pd_db = (object)array(
'cstm' => (object)array(
'table_name' => "customdata",
'table_version' => '1.0'
)
);
Though this seems like a pretty horrible idea...
It looks like you're trying to create an associative array, in which case you want:
$arr = array(
'key1' => 'val1',
'key2' => 'val2',
);
If you are actually wanting to use an object, object instantiation cannot be done with that syntax. You would have to create an object and assigned properties:
$obj = new stdObject;
$obj->key1 = 'val1';
Edit: Did not know that you can cast an array to an object. If that is your goal, tereško's way is better.
精彩评论