无法重新分配$ this? [英] Cannot re-assign $this?

查看:101
本文介绍了无法重新分配$ this?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有php版本4的服务器上有一个脚本,现在将其更改为php5,该脚本不再起作用.我收到此错误:

I have a script on a server that had php version 4. Now it is changed to php5 and the script does not function any more. I get this error:

致命错误:无法在URL database.php第88行中重新分配$ this

Fatal error: Cannot re-assign $this in URL database.php line 88

文件中是具有功能的类.里面是第88行:

In the file is a class that has a function. Inside is the line 88:

$this = new $db( $serv, $user, $pass, $dbName );

错误是什么意思,我该如何更改?

What does the error mean and how can I change it?

推荐答案

$this是一个特殊的变量",始终引用当前函数正在其中执行的 object .属于 class 的内部函数;但是,您不允许在其他任何地方使用它,并且您永远都不能分配给它.解决方案就是简单地重命名变量.

$this is a special "variable" that always refers to the object the current function is executing in. It only makes sense inside functions that belong to a class; however, you are not allowed to use it anywhere else, and you may never assign to it. The solution is simply to rename the variable.

这篇关于无法重新分配$ this?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆