I am attempting to fit an associative array declaration containing strings into a column width of 80 (style guide). This is being done in an abstract class. To fit within the 80 column width I am using the concatenation operator for php. See the following code snippet.
Original code format:
abstract class VideoBase
{
protected $config_types =
array('production' =>'Configures all hardware for production runs',
'development'=>'Configures project specific development connections if available. Otherwise, only out the window and heads down connections are made');
function __construct()
{
print_r($config_types);
}
function __destruct()
{
}
}
Attempted code format:
abstract class VideoBase
{
protected $config_types =
array('production' =>'Configures all hardware for production runs',
'development'=>'Configures project specific development connections '.
'if available. Otherwise, only out the window and '.
'heads down connections are made');
function __construct()
{
print_r($config_types);
}
function __destruct()
{
}
}
I receive the following error: PHP Parse error: syntax error, unexpected '.', expecting ')'
To my knowledge the above syntax is correct. The parse error only occurs when the associative array is declared inside the abstract class.
What am I doing incorrectly preventing this syntax from working?
Answer: As stated in the accepted answer below, the parsing error is due to the PHP Parser version not knowing how to handle the syntax when done in this manner. I need PHP version 5.6 or greater for this to work.
` tag or a `\r\n`. https://3v4l.org/2DBdq – Andreas Oct 19 '18 at 19:24