PHPNews

Are PHP developers functophobic?

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Friday August 10, 2012 - Permalink

There is this one thing that I noticed recently and that concerns me: PHP devs don’t use functions. Now, that was overly general, so let me clarify: PHP developers who have reached a certain degree of sophistication basically stop using plain functions - instead everything goes all classes and methods. At least that’s the observation I made when looking at various open-source libraries and …

Continue reading »


Cooperative multitasking using coroutines (in PHP!)

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Saturday December 22, 2012 - Permalink

One of the large new features in PHP 5.5 will be support for generators and coroutines. Generators are already sufficiently covered by the documentation and various other blog posts (like this one or this one . Coroutines on the other hand have received relatively little attention. The reason is that coroutines are both a lot more powerful and a lot harder to understand and explain. In …

Continue reading »


The case against the ifsetor function

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Friday January 10, 2014 - Permalink

Recently igorw wrote a blog post on how to traverse nested array structures with potentially non-existing keys without throwing notices. The current “idiomatic” way to do something like this, is to use isset() together with a ternary operator: $age = (isset($data['people'][0]['age'])) ? $data['people'][0]['age'] : null; The suggested alternative is a get_in function, which …

Continue reading »


Fast request routing using regular expressions

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Tuesday February 18, 2014 - Permalink

Some time ago I stumbled on the Pux routing library, which claims to implement a request router that is many orders of magnitude faster than the existing solutions. In order to accomplish this, the library makes use of a PHP extension written in C. However, after a cursory look at the code I had the strong suspicion that the library was optimizing the wrong parts of the routing process and I …

Continue reading »


Methods on primitive types in PHP

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Friday March 14, 2014 - Permalink

A few days ago Anthony Ferrara wrote down some thoughts on the future of PHP . I concur with most of his opinions, but not all of them. In this post I’ll focus on one particular aspect: Turning primitive types like strings or arrays into “pseudo-objects” by allowing to perform method calls on them. Lets start off with a few examples of what this entails: $str = "test foo bar"; $str->le…

Continue reading »


PHP's new hashtable implementation

Written by Nikita Popov - Published on Blog by nikic
Aggregated on Monday December 22, 2014 - Permalink

About three years ago I wrote an article analyzing the memory usage of arrays in PHP 5. As part of the work on the upcoming PHP 7, large parts of the Zend Engine have been rewritten with a focus on smaller data structures requiring fewer allocations. In this article I will provide an overview of the new hashtable implementation and show why it is more efficient than the previous implementation. …

Continue reading »