Thursday, 19 July 2018

php - Fatal error: Can't use method return value in write context (error info below)

If you are using PHP with a version < 5.5.0, you cannot check a functions return value directly with empty.




Note:



Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.




You have to assign it to a variable first. Further, you are missing a ).




Try:



$slab_enabled = $displayData->sa_params->get('slab_enable');
if(empty($slab_enabled)) { /*do stuff*/ };


If you do not know, which version you use, you can check with echo phpversion();

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...