note 68948 added to language.oop5.visibility
| From: | alberi at example dot com | Date: | Wed, 16 Aug 2006 21:47:20 +0000 |
| Subject: | note 68948 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115989@lists.php.net to get a copy of this message | ||
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->".
----
Server IP: 66.163.161.117
Probable Submitter: 81.23.148.200
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php
Edit -- https://master.php.net/note/edit/68948
Del: integrated -- https://master.php.net/note/delete/68948/integrated
Del: useless -- https://master.php.net/note/delete/68948/useless
Del: bad code -- https://master.php.net/note/delete/68948/bad+code
Del: spam -- https://master.php.net/note/delete/68948/spam
Del: non-english -- https://master.php.net/note/delete/68948/non-english
Del: in docs -- https://master.php.net/note/delete/68948/in+docs
Del: other reasons-- https://master.php.net/note/delete/68948
Reject -- https://master.php.net/note/reject/68948
Search -- https://master.php.net/manage/user-notes.php