Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts

    information regarding THIS

    Hi, i ran accross some code that used "this" in several places but i am unable to find where "this" is set. I did some googling and was unable to find some resources because i am not aware what keyword to search for.

    What is "this" ?
    Is it a php function?
    Javascript function?
    Just a standard variable that people use?
    a class?

    i dont know what it is and if it already has value or if i need to give it value.

    link to some documentation or any help appreciated, thanks so much.

  • #2
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    can you post the code or a portion of it, say, from the top down to where 'this' is showing.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    here is one, but it appears in others as well, the other one looks like some kind of class statment but i cant be sure.

    but here is this one(it pulls up an image on mouseover)

    Code:
    onmouseover="this.src='http://www.xxx.com/images/myimage.gif'
    but i cant find where this is set because im not sure what im looking for.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    $this is reserved and cannot be assigned to.
    Its a scope resolution for objects. $this resolves to this instance of a class, and PHP doesn't allow variable masking so $this->member and $this->method() must always be used. It is only usable within the scope of an object.
    I can't recall which version actually forced this, but I think somewhere between the 5.0 and 5.1 time $this was actually assignable. This was later changed to throw a fatal error. At least I think it was PHP that had done that.

    Edit:
    That is javascript, same concept it relies on the dom. this.src refers to this dom object's src property.

  • Users who have thanked Fou-Lu for this post:

    durangod (06-01-2011)

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Fou-Lu View Post
    I think somewhere between the 5.0 and 5.1 time $this was actually assignable. This was later changed to throw a fatal error. At least I think it was PHP that had done that.
    Yeah, it was right as/after 5.0 came out. Something like 6 years ago.

  • #6
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    thanks Fou-Lu sorry so late getting back to you, my third party mail client crapped out of me (MS changed its protocal for ssl) and i was upside down getting and sending emails to customers. what a day...

    I really appreciate the info. peace dave


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •