note 56356 added to keyword.paamayim-nekudotayim
| From: | JDS | Date: | Wed, 31 Aug 2005 14:10:01 +0000 |
| Subject: | note 56356 added to keyword.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94525@lists.php.net to get a copy of this message | ||
Using an anonymous class instance via the scope resolution operator does not appear to call the
constructor method of the class. Thus, any "stuff" set up within a constructor method
(the method called when creating a new instance of a class) will not get set up using anonymous
classes.
So for example something like this
<?php
Class A{
var $thing;
function A(
$this->thing = "hello";
)
function get ($var){
return $this->$var;
}
}
echo A::get('thing');
?>
will not print anything as A::thing does not get "set up" outside of the constructor.
You would have to create an instance of class A to get any value for A::thing.
For example:
<?php
$a = new A();
echo $a->get('thing');
?>
(prints "hello")
This is based on my observations and not from any official documentation. I may be wrong about the
details.
----
Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56356
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56356&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56356&report=yes
Search -- http://master.php.net/manage/user-notes.php