i am blocked by an incomprehensible syntax error that makes me crazy :/
The error displayed is Parse error: syntax error, unexpected '.', expecting ',' or ';'
This is the code that makes that:
class FamillePieceControllerCore extends FrontController
{
public $php_self = 'famille-piece.php';
private $webservice_url = _CICERONE_CONNECT_BASE_URL_ . 'WSC003&P2=0';
}
Where _CICERONE_CONNECT_BASE_URL_ is defined in a other file.
If i delete . 'WSC003&P2=0' the code works fine.
I don’t understand :/ Thanks for helping
ps: I use php 5.3.8
You cannot initialize a class property with an expression (like concatenation). Instead you must do it in the constructor:
From the documentation:
Constants defined with
define()are defined at runtime, so the value of_CICERONE_CONNECT_BASE_URL_isn’t known at compile time when the property is initialized.Update for later PHP versions:
Beginning with PHP 5.6, simple expressions are permitted in class property declarations as long as they can still be evaluated at compile time. So the original posted code would compile and execute correctly in PHP 5.6+. Anything requiring runtime evaluation, such as a function call or variable interpolation is still not permitted.