Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.