$this and php
by alamster in May 20th, 2008
PHP Tags: php oop
Little mistake on naming variable make me confuse for almost an hour.
$this
yes, $this is built-in variable that often use in OOP. By using $this, we refer to self referencing variable.
More in php.net manual
<?php
class A
{
function foo()
{
if (isset($this)) {
echo ‘$this is defined (’;
echo get_class($this);
echo “)\n”;
} else {
echo “\$this is not defined.\n”;
}
}
}
class
B
{
function bar()
{
A::foo();
}
}
$a = new A();
$a->foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>
Freelance Project:
- Online Marketing Expert by websolution71
- Nonpublic project #283208 by ekoolstra
- banners required asap by wbmasters
- Invitation card design by Formationsuk
- Nonpublic project #283205 by plennon
- Flash and HTML Partner Wanted by asonofhaiti
- Nonpublic project #283204 by maisaiah
- Michelle 01 by longterm1947
- Nonpublic project #283198 by ekoolstra
- Website similar to Yelp by gritz

No Comment
Random Post
Leave Your Comments Below