When developing in PHP, when you use empty to check the result returned by a function, an error will be reported: Fatal error: Can't use function return value in write context
For example, the following code:
Copy the code The code is as follows:
echo empty( strlen('test'));
Go to the PHP manual and see the following text where the empty function is described:
Copy the code The code is as follows:
Note : empty() only variables checks as anything else will result in a parse error. In other words, the following will not work: empty(trim($name)).
Conclusion: empty() only Detecting variables, testing anything that is not a variable will result in a parsing error!
Therefore, we cannot use empty to directly detect the value returned by the function. The solution to the above example is as follows:
Copy the code The code is as follows:
$length = strlen('test');
echo empty($length);
http://www.bkjia.com/PHPjc/736792.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/736792.htmlTechArticleWhen developing PHP, when you use empty to check the result returned by a function, an error will be reported: Fatal error: Can't use function return value in write context For example, the following code: Copy code code...