php empty 错误

WBOY
WBOYOriginal
2016-06-23 13:43:351075browse

【错误详情】:Fatal error: Can't use function return value in write context in ……

【错误经过】:  来看这么一段程序

[php]  view plain copy print ?

$value = $_POST['username'];   if (empty(trim($value))){       echoError('请输入用户名!');   }  
乍一看上去很简单,没什么问题,可经过异常排查后确定就是这一小段程序出现了上面的Fatal error~,于是首先怀疑自定义方法echoError的实现存在什么问题,可经过排查后问题不是出在这里,十分不解,最后经过查询手册发现empty()方法在最后有这么一小段解释:

Note: empty() 只检测变量,检测任何非变量的东西都将导致解析错误。换句话说,后边的语句将不会起作用: empty(addslashes($name))。 


明白了~ 程序结构改变:

[php]  view plain copy print ?

$value = trim($_POST['username']);   if (empty($value)){       echoError('请输入用户名!');   }  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn