[email protected] Posted November 30, 2007 Share Posted November 30, 2007 Hi all, am running a code created with php4 on a php5 engine and I am running into problems with the $this . In php4 its a variable and in php5 its a ref to a class object (if am right) I get the following error in a class "Fatal error: Cannot re-assign $this in {path}" which is caused by this line "$this = new $db( $serv, $user, $pass, $dbName );" How can i resolve this ? am thinking of renaming $this to something like $this_var but then this is likely not to work. Cheers olu. Link to comment https://forums.phpfreaks.com/topic/79569-problem-with-fatal-error-cannot-re-assign-this-php4-php5-issue/ Share on other sites More sharing options...
Wes1890 Posted November 30, 2007 Share Posted November 30, 2007 Try $this = new db( $serv, $user, $pass, $dbName ); Link to comment https://forums.phpfreaks.com/topic/79569-problem-with-fatal-error-cannot-re-assign-this-php4-php5-issue/#findComment-403029 Share on other sites More sharing options...
wildteen88 Posted November 30, 2007 Share Posted November 30, 2007 The variable $this is registered variable, You cannot create a variable called $this as it is used by PHP. You'll have to change your variable to something else, say $_this or $This Link to comment https://forums.phpfreaks.com/topic/79569-problem-with-fatal-error-cannot-re-assign-this-php4-php5-issue/#findComment-403054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.