php调用empty出现错误Can't use function return value in write context

简介: php调用empty出现错误Can't use function return value in write context 2012-10-28 09:33:22 | 11391次阅读 | 评论:0 条 | itokit  今天的一个简单程序: C/C++ Code复制内容到剪贴板 ...

php调用empty出现错误Can't use function return value in write context

2012-10-28 09:33:22 | 11391次阅读 | 评论:0 条 | itokit php调用empty出现错误Can't use function return value in write context

今天的一个简单程序:

C/C++ Code复制内容到剪贴板
  1. protected function _isLogin() {  
  2.    if(empty(cookie(C('itokit_com')))) {  
  3.        $this->error('未登录后台,请先登录', 'Public/login');  
  4.    }  
  5. }  

运行这个方法,竟然返回以下错误:
Can't use function return value in write context E:\www\www.itokit.com\js\Lib\Action\Jsadmin\CommonAction.class.php 第 16 行.

这个错误的原因是由于:empty函数参数必须为variable,不能为其它函数的返回值,包括str_replace,trim等等
而我的empty里使用了cookie有返回值的函数。所以就报了这个错误的了。
ok,知道错误原因,修改下即可了:

PHP Code复制内容到剪贴板
  1. protected function _isLogin() {  
  2.     $itokitname = cookie(C('JSADMIN_USER'));  
  3.     if(emptyempty($itokitname)) {  
  4.         $this->error('未登录后台,请先登录', 'Public/login');  
  5.     }  
  6. }  

好了,问题解决的了。大家如何有碰到像我这样的小问题,可以把变量先获取到,再使用empty哦。

php的其他使用错误相关文章:
1、如何正确理解PHP程序错误信息的表示含义
2、如何正确理解PHP的错误信息
3、新手入门:PHP网站开发中常见问题汇总

目录
相关文章
|
4月前
|
JavaScript 前端开发
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
168 0
|
5月前
|
PHP Python
总是忘了isset与empty的区别-php随记
@(狂汗)都是5个单词,不能从字数上编口诀.... isset 判断变量是否已存在,如果变量存在则返回 TRUE,否则返回 FALSE。
21 0
|
10月前
|
PHP
PHP报错Call to undefined function utf8_decode()的解决方案
PHP报错Call to undefined function utf8_decode()的解决方案
|
10月前
|
PHP
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
38 0
|
10月前
|
数据可视化 PHP
漏刻有时数据可视化大屏常见问题(1): Can’t use function return value in write context
漏刻有时数据可视化大屏常见问题(1): Can’t use function return value in write context
34 0
|
10月前
|
Linux
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
77 0
PHP踩坑记录-empty判断浮点型
PHP踩坑记录-empty判断浮点型
74 0
|
消息中间件 PHP
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
136 0
|
Linux C++ Windows
error: ‘_beginthreadex‘ undeclared (first use in this function); did you mean ‘SDL_beginthread‘?
error: ‘_beginthreadex‘ undeclared (first use in this function); did you mean ‘SDL_beginthread‘?
514 0
error: ‘VPX_IMG_FMT_RGB32’ undeclared (first use in this function); did you mean ‘VPX_IMG_FMT_NV12’?
error: ‘VPX_IMG_FMT_RGB32’ undeclared (first use in this function); did you mean ‘VPX_IMG_FMT_NV12’?
82 0