我有一个新的问题,为空或修剪功能。我猜trim不能返回布尔值,但是我不知道为什么?:C
$author = htmlentities($_POST['author']);
if(empty(trim($author))) $author="Unknown";
给我这个错误:
致命错误:无法在写入上下文中使用函数返回值
分别修剪字符串变量。trim()无法返回布尔值,因为它返回的是字符串值。如果您的意思是empty()与trim()组合不能返回布尔值,那么我认为这很奇怪,应该可以工作。尝试这个:
$author = htmlentities($_POST['author']);
$author = trim($author);
if(empty($author)){
$author = "Unknown";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句