note 68948 deleted from language.oop5.visibility by felipe
| From: | felipe@php.net | Date: | Mon, 24 Mar 2008 23:00:13 +0000 |
| Subject: | note 68948 deleted from language.oop5.visibility by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137516@lists.php.net to get a copy of this message | ||
Note Submitter: alberi at example dot com
----
There is such nonstricted "feature" with self:: on dinamic & static calling of methods
not declared as static:
<?
class foo
{
static $counter;
public function bar($i=0)
{
if ($i) self::$counter = $i;
echo ' bar: $this var ', isset($this)?'exists':'missing',
"\n";
self::mar();
if (--self::$counter)
self::bar();
}
public function mar()
{
echo ' mar: $this var ', isset($this)?'exists':'missing',
"\n";
}
}
$foo = new foo();
echo "\nDINAMIC CALLING:\n";
$foo->bar(2);
echo "\nSTATIC CALLING:\n";
foo::bar(2);
# OUTPUT:
#
# DINAMIC CALLING:
# bar: $this var exists
# mar: $this var exists
# bar: $this var exists
# mar: $this var exists
#
# STATIC CALLING:
# bar: $this var missing
# mar: $this var missing
# bar: $this var missing
# mar: $this var missing
#
#
# executed under PHP 5.1.1 (cli) (built: Nov 27 2005 21:39:02)
?>
In other words, in dinamic called function the "self::" selector will be interpreted as
"$this->".