Jump to content

[SOLVED] $this-> ????


kwdrysdale

Recommended Posts

Hi.  I was truly excited to find this site and look forward to visiting often and learning as much as I can so that I can work more in PHP and then be able to return the favour and help others learn as well.  I am really new to PHP but have some general programming experience from my younger days and in school.  I'm not scared to try things and totally screw up a file (as I have done over and over as I learned how to interact with a database) and learn most things really quickly. 

 

On with the question...I have tried searching the net, tried searching here, but because most search engines take out the special characters I get a whole lot of articles containing the word "this."  :)  I am working on modifying a login script (btw the phpfreaks login script would be GREAT to check out!) and don't really know what $this-> means.  Here is an example of what I have in some code:

 

   function Session(){
      $this->time = time();
      $this->startSession();
   }

 

That is one small portion.  There are other spots where it looks like it is defining a variable such as:

 

if(!$this->logged_in){
         $this->username = $_SESSION['username'] = GUEST_NAME;
         $this->userlevel = GUEST_LEVEL;
         $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      }

 

I am not asking anyone to tell me exactly what is happening in the script as I have a basic understanding of what most things are doing, just not a detailed understanding of some of the code yet.  "$this->" is something that I see a lot in this script and is something I would like to be able to understand more.  Is there somewhere I can find information on this?  I have tried php.net but searching is impossible as explained above.  Any help would be greatly appreciated.  Thanks.

 

Kevin

Link to comment
Share on other sites

Its a nomenclature dealing with OOP based programing.  It is talking about an array $this and then the item with the key time so $this['time'] is another way to write it.  I personally don't use OOP as it seems to complicate things, but some people speak very highly of it.  all it is doing though is setting an array node's value.

 

fyi OOP = object oriented programing

Link to comment
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.