News Feed
Sections




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

Till Klampaeckel's Blog:
Monkey patching in PHP
June 23, 2010 @ 10:31:09

In a new post to his blog today Till Klampaeckel takes a look at monkey patching in PHP - a way to replace functions at runtime.

I haven't really had the chance or time to play with PHP 5.3 until recently when Ubuntu 10.04 upgraded my local installations and kind of forced me to dive into it a little. And I'm also probably the last person on the planet to notice, but namespaces in PHP 5.3 allow you to monkey-patch core PHP code. [...] One of the more common applications is stubbing (or mocking) code in unit tests.

He includes a code sample showing how you can use a simple namespace hack to call a function from another namespace named the same as an internal one - in this case strlen.

0 comments voice your opinion now!
monkeypatch namespace runkit


blog comments powered by Disqus

Similar Posts

David Coallier's Blog: PHP Namespaces, how do YOU use them?

Antony Dovgal's Blog: 5.3 snapshots are available

David Coallier's Blog: PHP Namespaces (Part 2: Namespace constants)

Ben Ramsey's Blog: Flickr Namespace and array_multisort() Issues

Ben Ramsey's Blog: Flickr Namespace and array_multisort() Issues


Community Events





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


framework community language list symfony series interview release deployment zendserver voicesoftheelephpant introduction laravel tips api threedevsandamaybe bugfix conference podcast code

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