Appearance
Can't use function return value in write context?
In PHP, this error occurs when a function's return value is used in a context that expects a variable (a "write context"). This commonly happens with language constructs like isset(), unset(), or when attempting reference assignment. (Note: empty() was updated in PHP 5.5 to accept expressions, but the error remains common for the other constructs.)
For example, this will trigger the error:
php
isset(trim($str));The error happens because these constructs require a variable, not a function result. To fix it, assign the function's return value to a variable first, then pass that variable to the construct:
php
$trimmed = trim($str);
isset($trimmed);This also applies to unset() and reference assignment:
php
// Incorrect
unset(trim($str));
$ref = &trim($str);
// Correct
$value = trim($str);
unset($value);
$ref = &$value;