Saturday, 9 December 2017

php - Why I can't use get_cfg_var() to assign a custom setting value to an instance variable








I am
doing the
following:




class
JConfig {
public $var =
get_cfg_var('mySetting');
}
?>


If
I do that I received a compile error that says:





syntax
error, unexpected '(', expecting ',' or
';'




If I do
echo get_cfg_var('mySetting') outside the class it works just
fine.
If I assign get_cfg_var('mySetting') to a
local variable it works just fine.



Anyone has
any idea why I can't assign it to a instance variable?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...