Re: context when calling non static method of class in a static way

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

 



ah i forgot e_all doesnt include e_strict. with error_reporting(-1 / E_ALL | E_STRICT) i see the errors. so i think i am right that the use of that special behavior of php is not a good idea. thank you guys!

Am 23.05.2011 00:32, schrieb Richard Quadling:
On 22 May 2011 22:44, Simon Hilz<simon.hilz@xxxxxx>  wrote:
i cant reproduce that error. which php version do you use?
i've coded an example for a "behavior"-pattern:

Try with ...

<?php
error_reporting(-1);
ini_set('display_errors', 1);
class Car {
...

I get output of ...

Fuel of my new BMW with consumption 7.2l/100km: 0<br>call
TankUpBehavior::tankUp (100)<br>
Strict Standards: Non-static method TankUpBehavior::tankUp() should
not be called statically, assuming $this from incompatible context in
D:\Work\t1.php on line 50
Fuel after tank up 100 l: 100<br>call DriveBehavior::drive (24)<br>
Strict Standards: Non-static method DriveBehavior::drive() should not
be called statically, assuming $this from incompatible context in
D:\Work\t1.php on line 50
Fuel after driving 24 km: 98.272<br>




--
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