News Feed
Sections




News Archive
feed this:

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

Andrew Podner:
Overloading Create PHP Class Methods on the Fly
March 06, 2013 @ 11:51:57

Andrew Podner has a new post today looking at dynamic class method creation in PHP - aka "overloading" with the __call magic method.

What is overloading and what would I need it for? [...] In most languages, overloading just means you can have multiple methods with the same name, but they just had a different number/type of arguments. In PHP, it is a little different. Overloading in PHP means that you can actually create dynamic function names and the behavior will be dependent upon the function name that is used.

He gives an example through a sample application, first stating the requirements the business has for it then showing how to use the "__call" method to handle "getBy" requests made to a database class. It searches the database based on the field (ex. "getByusername" searches on "username") and he includes two examples of it in use. He also briefly touches on the use of the "__callStatic" magic method for handling static method calls similarly.

0 comments voice your opinion now!
method overloading magicmethod call callstatic getby


Content With Style:
buggy behaviour of parent in PHP 5.3.3
December 20, 2010 @ 09:43:56

On the Content with Style blog today they take a look at some buggy functionality with parent:: they've found in the latest version of PHP, 5.3.3.

So, this app I hadn't been looking at in a few months did not work at all. I traced the bug down to a method that itself called a parent method. The parent only contains __call and __callStatic methods, and for some reason __callStatic was called, although the class it was called from was an object instance.

After using some sample code from the PHP manual, they spotted how things truly worked - the call is always sent to __callStatic when called from the extending class but not when called directly. Apparently they aren't the only ones that noticed the bug but noted that it was removed in PHP 5.3.4 to fix the issue.

0 comments voice your opinion now!
bug version parent static callstatic method


Gergely Hodicska's Blog:
What is new in PHP 5.3 - Part 4
November 20, 2007 @ 09:38:00

Gergely Hodicska has posted part four of his "what's new in PHP 5.3" series - a sort of "wrapup" for some of the smaller features that have been added. Among them are:

  • __callStatic
  • OpenID support
  • user.ini user defined ini functionality
  • dynamic static calls
  • XSLT profiling

...and many more. Check out the post for more to add to the list and for some brief examples of the ones already mentioned.

0 comments voice your opinion now!
callstatic openid xslt profiling userini new php5 callstatic openid xslt profiling userini new php5


Gergely Hodicska's Blog:
What's new in PHP 5.3 - part 1 namespaces
November 14, 2007 @ 12:50:00

Gergely Hodicska has started a mini-series of posts centering about what's going to be coming in the next major release of PHP, version 5.3. The first article has been posted today focusing on one of the more popular topics - namespaces.

In my previous post I mentioned that PHP 5.3 will be released in early 2008 so I think it's just in time to talk about the features of this version. [...] The big gun features are namespaces, late static binding and mysqlnd, but there are other interesting improvements, for example __callStatic, dynamic static calls. In this part of this series we are going to analyze namespaces in detail.

Included in the post are a "before" and "after" example of namspacing in a PHP application, code examples of namespaces in action, simple porting of current PHP 5.2 applications up to 5.3 and working with __autoload and Reflection.

0 comments voice your opinion now!
namespace php5 callstatic latestaticbinding tutorial namespace php5 callstatic latestaticbinding tutorial


Johannes Schlüter's Blog:
PHP 5.3 Update
October 13, 2007 @ 13:30:00

Johannes Schlüter, the new release manager for the PHP 5.3 series, has posted an update on the progress of the release including a brief list of the new things included in the update.

Since a few hours we're having, thanks to Edin, Windows snapshots for the upcoming PHP 5.3 release. In combination with the latest sources from CVS everybody should be able to test the current state.

Included in his list of updates are things like: namespaces, late static binding, the __callStatic magic method and the mysql native driver (mysqlnd). He also recommends that, if you're currently running something in the PHP 5.2.x series, you update to the latest on that before making the jump to PHP 5.3 when it comes out.

0 comments voice your opinion now!
php5 update namespace callstatic latestaticbinding mysqlnd php5 update namespace callstatic latestaticbinding mysqlnd



Community Events





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


composer framework language version release voicesoftheelephpant series artisanfiles library community tool list opinion security symfony introduction conference laravel interview podcast

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