I have used {{$property.[Rent or Sale]}} or {{$property[Rent or Sale]}} for getting a value for the key Rent or Sale.
It is showing syntax error unexpected')' expected ']'.
I have used {{$property.[Rent or Sale]}} or {{$property[Rent or Sale]}} for getting a value for the key Rent or Sale.
It is showing syntax error unexpected')' expected ']'.
Firstly, According to best practices of PHP, we should never use space in array keys.
Secondly, This is fixed by me and my friend @curos. The issue was with the improper regular expression which was interpreting 'or' as default keyword. The following is the method having regex problem.
public function compileEchoDefaults($value)
{
return preg_replace('/^(?=\$)(.+?)(?:\s+or\s+)(.+?)$/s', 'isset($1) ? $1 : $2', $value);
}
Which is updated as following:
public function compileEchoDefaults($value)
{
return preg_replace('/^(?=\$)([^\'"]+?)(?:\s+or\s+)(.+?)$/s', 'isset($1) ? $1 : $2', $value);
}
The above method is in vendor/laravel/framework/src/compilers/BladeCompiler.php
This updated regular expression will not interpret 'or' as keyword.
please see : This bug has been fixed by laravel