Jump to content

bug or syntax error?


casper_ghost

Recommended Posts

Hi all

 

while in the process of learning php, I wrote some code and couldn't work out why it wouldn't work,

 

After going through everything with a fine tooth comb I couldn't see the problem.

Then out of luck I removed

 

$this 

 

I had assigned as a variable and it worked. replacing it back into the code broke it again.

 

Is this a bug or does it mean something in php?

Link to comment
https://forums.phpfreaks.com/topic/254437-bug-or-syntax-error/
Share on other sites

$this is reserved. See the manual for more info:

The pseudo-variable $this is available when a method is called from within an object context. $this is a reference to the calling object (usually the object to which the method belongs, but possibly another object, if the method is called statically from the context of a secondary object).
Link to comment
https://forums.phpfreaks.com/topic/254437-bug-or-syntax-error/#findComment-1304624
Share on other sites

Additionally, you should be developing with the following directives set in your php.ini file (then restart Apache):

error_reporting = -1

display_errors = On

 

If you had error_reporting set appropriately, you would have gotten this error:

Fatal error: Cannot re-assign $this in /Applications/MAMP/test.php . . .

Link to comment
https://forums.phpfreaks.com/topic/254437-bug-or-syntax-error/#findComment-1304625
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.