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

Johannes Schluter's Blog:
HashTables
August 23, 2010 @ 08:58:43

Johannes Schluter has a new post to his blog on another PHP internals related topic - hashtables.

While preparing my "PHP Under The Hood" talk for the Dutch PHP Conference there was a question on IRC about extension_loaded() being faster than function_exists(), which might be strange as both of them are simple hash lookups and a hash lookup is said to be O(1). I started to write some slides for it but figured out that I won't have the time to go through it during that presentation, so I'm doing this now.

He talks about array storage (a "real" array), numeric and string-based keys, the internals of how each is stored and how the differences make the one function faster than the other (hint: it's all about collisions).

0 comments voice your opinion now!
hashtable array storage variable functionexists extensonloaded


SitePoint PHP Blog:
How to Handle Unloaded PHP Extensions at Runtime
March 26, 2010 @ 09:10:13

On the SitePoint PHP blog today Craig Buckler has a suggestion on how to handle unloaded extensions in your application in case you need to define a failover.

Unless you're creating very simple applications, you will soon require one or more PHP extensions. Extensions are code libraries which extend the core functionality of the language. [...] What happens when you want to move your web application to another host or platform where a different set of extensions are configured?

Using the extension_loaded function built into PHP, you can create intelligent code that can fall back on a different technology if needed. In his example its trying to check for the GD graphics extension and echoing and error message if it's not found. The function_exists function can be used similarly.

0 comments voice your opinion now!
extension runtime functionexists extensionexists tutorial


Larry Garfield's Blog:
Drupal 7 gets introspective code registry
May 08, 2008 @ 12:53:14

Larry Garfield talks about a new feature of Drupal 7 in a new post to his blog - the new introspective code registry that's been introduced in this latest version.

As a GHOP Task , Cornil did a performance analysis of Drupal and found its two largest performance drains were the bootstrap process and the theming layer. Quite simply, Drupal spends too much time including code. [...] Fortunately, Drupal 7's self-learning code registry system has just landed, which should obliterate most of the wasted bootstrap cost.

Larry describes the "heart of it all", the token_get_all call, that parses through an entire PHP file, splitting out things like classes included and functions called. This is passed through a function_exists call to the current script and, if it's already there, the file isn't included repetitively.

0 comments voice your opinion now!
drupal cms registry tokengetall system functionexists


EdFinkler's Blog:
Determining if a function is *really* available in PHP
March 29, 2007 @ 07:02:14

In this new post to his blog, Ed Finkler talks about some tests he worked up to discover if a function is available in PHP or not while working on the latest version of PHPSecInfo).

is_callable() will return TRUE even if a function has been disabled in php.ini with disabled_functions (which, in my mind, is contrary to what 'is_callable' implies). function_exists() will return FALSE if the function is disabled in php.ini, but will return TRUE if the function is being blocked by safe_mode.

So, to help counter these issues, he checks first to see if the exec('id') option works - checking it work function_exists and the setting for safe_mode (disabled). If it doesn't pass, he moves on to the posix_* function and tests then with a function_exists.

0 comments voice your opinion now!
function available exec posix iscallable functionexists function available exec posix iscallable functionexists



Community Events





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


bugfix introduction symfony library language framework package install voicesoftheelephpant zendserver community api release series deployment interview podcast laravel unittest opinion

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