Re: classes and objects: php5. The Basics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
dave

Hi 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux