Re: classes and objects: php5. The Basics
| From: | Daniel Kullik | Date: | Tue, 16 Jan 2007 14:54:51 +0000 |
| Subject: | Re: classes and objects: php5. The Basics | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247150@lists.php.net to get a copy of this message | ||
Cheseldine, D. L. wrote:
Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards daveHi Dave, the example code seems to be damn old. It doesn't even make use of the access control modifiers. To answer your question: foo() can be called statically this way since PHP5 still supports the PHP4-way of calling static methods (backwards-compatibility). In PHP4 one can call any method statically, since there is no "static" modifier in PHP4. Hint: In this case PHP5 generates an error of the type E_STRICT, which tells you that one can't call a given instance method statically. error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 'on'); Regards, Daniel