News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell's Blog:
Declaring Static Methods in PHP
December 10, 2010 @ 08:40:45

Lorna Mitchell has a new post to her blog today talking about static methods and how to use them correctly in your code (as discovered accidentally in her own code).

I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that: static functions can be called dynamically and dynamic functions generate an E_STRICT error if called statically.

She illustrates with some sample code that, when run with E_ALL and E_STRICT throws a warning from the strict side about calling a non-static method statically. She also talks about why it throws this warning for the non-static call on a static method. She also explains why, when a static method is called dynamically, no warning is thrown.

0 comments voice your opinion now!
declaring static method warning strict


blog comments powered by Disqus

Similar Posts

DevShed: Using Method Call Overloading in PHP 4

The Bakery: Some ideas to organize your CSS files and autoload them in CakePHP

Samantha Quinones: Juggle Chainsaws, Not Types

Tim Koschuetzki's Blog: Composing Methods: Substitute Algorithmn

DevShed: Using Method Call Overloading in PHP 4


Community Events

Don't see your event here?
Let us know!


series introduction framework php7 opinion release extension community conference interview example podcast performance voicesoftheelephpant library application symfony2 version laravel api

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework