I've got a question about concatenating a property within a class.
Here's sample code
define('ACTION', 'say something');
class Something {
var $text = ACTION . " else";
function prnt() {
echo ACTION;
}
}
Doing this produces the error.
Parse error: syntax error, unexpected '.', expecting ',' or ';' in C:\apache\htdocs\test.php on line 6
Is there a reason for this?
Additionally i'm unable to define a constant in a class.
Here's another code example.
class Something {
define('ACTION', 'say something');
....
}
This example produces this error message.
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\apache\htdocs\test.php on line 6
Taken from the php manual.
Constants may be defined and accessed anywhere without regard to variable scoping rules;
http://www.php.net/manual/en/language.constants.php
So am I wrong to think that one should be able to define a constant within the class body.