I have strange behavior empty() function on different environments. I'm wondering if it's because of php version or php config or something else. The following code is giving me error on production server and there is no error on my local development environment. I would prefer it to be the other way around - no error on prod but show error on local.
if ( !empty($f && !empty($g)) ) {
print 'condition is true';
}
else {
print 'condition is false';
}
Obviously there is a bug related to the placement of the parenthesis, which should be just after $f variable instead of end of condition. I got this error on production server:
PHP Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND), expecting ')' in /opt/webdata2/site5073/openfed-7.x-2.17/sites/all/themes/custom/ombudsman/template.php on line 79
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.