note 103309 added to function.get-called-class
| From: | uebele at osu1 dot php dot net | Date: | Wed, 06 Apr 2011 16:14:44 +0000 |
| Subject: | note 103309 added to function.get-called-class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178568@lists.php.net to get a copy of this message | ||
SEE: http://php.net/manual/en/language.oop5.late-static-bindings.php
I think it is worth mentioning on this page, that many uses of the value returned by
get_called_function() could be handled with the new use of the old keyword static, as in
<?php
static::$foo;
?>
versus
<?php
$that=get_called_class();
$that::$foo;
?>
I had been using $that:: as my conventional replacement for self:: until my googling landed me the
url above. I have replaced all uses of $that with static with success both as
<?php
static::$foo; //and...
new static();
?>
Since static:: is listed with the limitation: "Another difference is that static:: can only
refer to static properties." one may still need to use a $that:: to call static functions;
though I have not yet needed this semantic.
----
Server IP: 192.41.42.26
Probable Submitter: 24.172.72.66
----
Manual Page -- http://www.php.net/manual/en/function.get-called-class.php
Edit -- https://master.php.net/note/edit/103309
Del: integrated -- https://master.php.net/note/delete/103309/integrated
Del: useless -- https://master.php.net/note/delete/103309/useless
Del: bad code -- https://master.php.net/note/delete/103309/bad+code
Del: spam -- https://master.php.net/note/delete/103309/spam
Del: non-english -- https://master.php.net/note/delete/103309/non-english
Del: in docs -- https://master.php.net/note/delete/103309/in+docs
Del: other reasons-- https://master.php.net/note/delete/103309
Reject -- https://master.php.net/note/reject/103309
Search -- https://master.php.net/manage/user-notes.php