I have the following code sample, which produces an error with the included constant when it is run. Could someone please show me where this is going wrong?
class Template {
private $headers = "<link rel=\"stylesheet\" type=\"text/css\"
href=\"" . ROOT . "system/stylesheets/universal.css\" />";
... More variables and methods
}
Here is the error I receive. I am sure that the ROOT constant is defined, just outside of this class:
Parse error: syntax error, unexpected '.', expecting ',' or ';' in <page.php> on line <line number>
Thank you for your time,
spryno724
You cannot specify non-static values as your members default values. And you’re trying to perform dynamic (runtime) things – concatenation of the strings.
Usage:
Also – I missed that you’re using just instance variables, not constants. In this case you can also use initialization in constructor: