You are here: Re: Can someone explain ($this->varname) to me.. « PHP Programming Language « IT news, forums, messages
Re: Can someone explain ($this->varname) to me..

Posted by 4sak3n 0ne on 08/31/07 17:52

On Aug 31, 10:44 am, stiki <lapto...@gmail.com> wrote:
> How and what does this mean in php: ($this->varname)
>
> I can't seem to find this by searching Google, because the "->" are
> removed from my search query.
>
> Cheers,
> Igor Terzicwww.stikimedia.com

-> is used when referring to a classes inner workings. $this is a
special variable used within a class to refer to itself.

Example:
----------------------------------------
class Example{
var $classVariable = "Something";

function testFunction(){
echo "I'm just a simple function.";
}

function show(){
$this->testFunction();
}
}

$c = new Example;
$c->testFunction(); // Returns I'm just a simple function.
$c->show(); // Returns I'm just a simple function.
echo $c->classVariable; // Returns Something
------------------------------------------

Hope that clears thing up for you.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация