Please, what is wrong with the following code? And what is the correct way to do it?
class SomeClass {
var $someVar = trim('some value');
}
The error I get:
PHP Parse error: syntax error,
unexpected ‘(‘, expecting ‘,’ or ‘;’
in /tmp/testik.php on line 3
Thank you very much.
You cannot run a function there. Only constant values are allowed as initialization values to object properties. If you need the
trimfunction to initialize $someVar, run it in the constructor: