Used in conjunction with classes. class Foo { var bar;
function Foo($bar) { $this->bar = $bar; } } $foo = new Foo("foobar"); echo $foo->bar; // "foobar" For interests sake here's the same in C++ (correct me if I'm wrong it's been a long time since I used C++ or pointers). class Foo { char *bar; function Foo(bar) { this.bar = bar; } } Foo *foo = new Foo("foobar"); cout << (*foo).bar; // "foobar" // which also works as. cout << foo->bar; // "foobar" -----Original Message----- From: Stephano Mariani [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 12:57 To: 'Kearns, Terry'; 'S.Murali Krishna'; 'Jack' Cc: [EMAIL PROTECTED] Subject: RE: [PHP] What is "->" mean in php? PHP uses -> as C++ uses ".", since PHP already uses "." for strings. Stephano Mariani > -----Original Message----- > From: Kearns, Terry [mailto:[EMAIL PROTECTED]] > Sent: Friday, 8 March 2002 12:28 AM > To: 'S.Murali Krishna'; Jack > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP] What is "->" mean in php? > > Because I'm not a hacker on the PHP engine, I don't really know but I also > saw this symbol when learning C++ recently. It is used in C++ as a > shortcut > to dereferencing and accessing an objects properties/methods on objects > which are on the free store (heap). Normally C++ uses the dot operator to > access methods/properties (eg. "foo.do()"), but when the object needs to > first be dereferenced, then "foo->do()" can be used as a shortcut to > "(*foo).do()". > > Of course, this doesn't help you at all does it :) But I thought it was an > interesting connection to C++ and maybe hints at how PHP internally > manages > objects. Perhaps it's just a coincidence. > > [TK] > > > -----Original Message----- > > From: S.Murali Krishna [mailto:[EMAIL PROTECTED]] > > Sent: Monday, 4 March 2002 9:48 PM > > To: Jack > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP] What is "->" mean in php? > > > > > > > > If you have any Object Oriented Programming experience, then > > you may not had asked this. Its a operator to access methods, > > and variables inside a instance of a class , in which the > > variable before "->" is the instance of the class and the > > latter is a method or variable of that class. This is what I > > know, if you have any explanatory docs, pls let me know. > > > > > > > > On Mon, 4 Mar 2002, Jack wrote: > > > > > Dear all > > > There is one symbol in PHP that i always see is "->", could > > anyone pls > > > tell me what is this, and what does that do? Here is the > > statement i > > > saw could some pls explain what it means? > > > > > > if (!empty($row->usd_period) > > > > > > Thx a lot > > > Jack > > > [EMAIL PROTECTED] > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > <[EMAIL PROTECTED]> > > ------------------------------------------------------------------- > > We must use time wisely and forever realize that the time is > > always ripe to do right." > > > > -- Nelson Mandela > > ------------------------------------------------------------------- > > > > > > -- > > 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 -- 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