Hi, Steve.  

$this refers to a specific instance of a class.  The -> accesses a property
or method associated with this class.

So, in your class, say it's class car, and in your constructor you want to
initialize the color to red, you'd do 
$this->color = $red;

Outside of the class, with your $car variable, you'd change it by using 
$car->color = $red;

It's similar to the Java "." accessor (and the "this" is also similar to
Java's this).

I hope this helped!

-Natalie

-----Original Message-----
From: Steve Buehler [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 29, 2002 10:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] $this->


I am not an expert at PHP and have been learning it through questions, 
books, online help, etc....  I guess like most people. :)  Anyway, I see a 
lot of scripts that use $this->something and was wondering if this was just 
another variable or if the "->" has any special meaning.  One script from 
the PHPLIB (menu.inc) has this:
$this->setup();
and there are no other times in that .inc file that lists that.  The only 
other thing that comes close is just the "funtion setup()".  This is not 
the only program that I see this in and am just wondering about it and 
trying to see if it is something that I should be using in my scripts.  The 
only time that I use this is when getting results from a mysql query like
this:
        $result=mysql_query("SELECT $team from games where game_id =
'$game_id'");
        while (($row = mysql_fetch_object($result))){
                $input = $row->$team;

Hopefully somebody can explain this to me.

Thanks in Advance
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to