note 73037 added to keyword.paamayim-nekudotayim
| From: | deadimp at gmail dot com | Date: | Wed, 07 Feb 2007 05:04:17 +0000 |
| Subject: | note 73037 added to keyword.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123028@lists.php.net to get a copy of this message | ||
I've noticed that you can't easily obtain a re-scoping of a function-to-object by external
means, and it can only really be done by functions ["methods" to be proper] inside the
class.
I dub this phenomon "inability to externally modifiy scope resolution of class method",
'cause I don't really know the technical name. (Maybe something else along the lines of
"inability to combine scope resolution and member selector operators".)
Enough of this, on to the example:
<?php
class Base {
var $a=5;
function Func() {
echo "Base::Func $this->a<br>";
}
}
class Child extends Base {
function Func() {
$this->a=35;
Base::Func();
//$this->Base::Func(); //Won't work either
echo "Child::Func $this->a<br>";
}
}
$obj=new Child;
$obj->Func(); //That works, outputs as expected
$obj->Base::Func(); //ERROR - See below
?>
As for the error, I get the Hebrew "double colon", as Shachar Shemesh mentioned:
"parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM"
I find it odd that I can't do this, and using C++ (where you are able to do this), I feel
restricted in this sense.
And I can't think of any workarounds right now, aside from using this scope resolution in the
class scope.
NOTE: I'm using PHP 5.0.5 right now (used to be using 4.x, but might've switched it in
xampp)
----
Server IP: 69.147.83.197
Probable Submitter: 74.192.112.67
----
Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
Edit -- https://master.php.net/note/edit/73037
Del: integrated -- https://master.php.net/note/delete/73037/integrated
Del: useless -- https://master.php.net/note/delete/73037/useless
Del: bad code -- https://master.php.net/note/delete/73037/bad+code
Del: spam -- https://master.php.net/note/delete/73037/spam
Del: non-english -- https://master.php.net/note/delete/73037/non-english
Del: in docs -- https://master.php.net/note/delete/73037/in+docs
Del: other reasons-- https://master.php.net/note/delete/73037
Reject -- https://master.php.net/note/reject/73037
Search -- https://master.php.net/manage/user-notes.php