PHP Fatal Error Fix: Can’t use method return value in write context
PHP compiler generate fatal error if you use function return value in read/write context. Although this is not applicable for all PHP supported function but PHP function like empty does not support use of the function in this way. In other words, php empty function cannot check the return value of a function or method. It can only check variables so use only variable inside empty function. Any other function or expression inside empty function will lead to generate fatal error.
Example Problem Solution:
Wrong
if(empty(trim($testimony))) echo “Empty”; else echo “Not Empty”;Correct
$testimony = trim($testimony);
if(empty($testimony)) echo “Empty”; else echo “Not Empty”;
Wrong
if(empty($bobj->get_results(‘post’)) { // Processing Code }Correct
$tmp = $bobj->get_results(‘post’);
if(empty($tmp)) { // Processing Code }
Recent Comments