Re: Stupid question
| From: | Robert Cummings | Date: | Wed, 17 Mar 2004 21:01:11 +0000 |
| Subject: | Re: Stupid question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180744@lists.php.net to get a copy of this message | ||
On Wed, 2004-03-17 at 15:55, Jeff McKeon wrote:
> I've been using PHP for about 6 months and I'm ok with it but I'm now
> starting to get into more advanced stuff and inheriting project that
> other people have coded. One of the major stumpers I have is any line
> of code that contains:
>
> $this->
>
> What does this do? I know it has something to do with classes but can't
> quite get my head around it.
>
> Thanks,
>
> Jeff
It refers to the object upon which the class method was called. So
outside of the class you might have:
$foo = new FooClass();
$foo->doSomething();
then inside the class you might have the following:
class FooClass
{
function doSomething()
{
$this->doSomethingElse();
}
function doSomethingElse()
{
$foo = 1;
return (++$foo === $foo++); // ;)
}
}
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'