This article mainly introduces the solution for the PHPempty function to report an error when detecting a non-variable. if you need a friend, refer to PHP development, when you use empty to check the results returned by a function, the following error occurs: Fatal error: Can't use function return value in write context.
For example, the following code:
The code is as follows:
Echo empty (strlen ('test '));
Go to the PHP manual and check the following text in the description of the empty function:
The code is as follows:
Note: empty () only checks variables as anything else will result in a parse error. In other words, the following will not work: empty (trim ($ name )).
Conclusion: empty () only detects variables, and any non-variables will cause parsing errors!
Therefore, we cannot use empty to directly detect the value returned by the function. the solution in the preceding example is as follows:
The code is as follows:
$ Length = strlen ('test ');
Echo empty ($ length );