Blog by nikic. Find me on GitHub, StackOverflow and Twitter. Learn more about me.

Methods on primitive types in PHP

This article discusses the merits of allowing method calls on primitive PHP types, like strings and arrays.

Fast request routing using regular expressions

This article describes a number of techniques to improve performance of regular expression based dispatch processes, as used in request routing or lexing.

The case against the ifsetor function

The ifsetor function can be used to suppress notices when accessing array indices. This post discusses some of the issues this function has and how to resolve them.

Cooperative multitasking using coroutines (in PHP!)

This post explains how coroutines can be used for task scheduling and handling asynchronous operations in a synchronous-seeming way.

Are PHP developers functophobic?

PHP developers don't seem to like normal functions much. I think that this is related to the one-to-one class to file mapping that PHP has inherited from Java.

How to add new (syntactic) features to PHP

In this post I'm describing how one can add new syntax to PHP. At the same time, this post can be seen as a general introduction to the workings of the Zend Engine.

What PHP 5.5 might look like

PHP 5.5 is still in an early development stage, but there are already many proposals that are being worked on. This post gives some insights into the recent developments.

A plea for less (XML) configuration files

Configuration files typically use XML or some other domain specific language. But why? Why not just use the usual programming language instead?

PHP solves problems. Oh, and you can program with it too!

PHP is a great language to start programming. And once you started, PHP is also good for "real" programming. So what's the problem?

The true power of regular expressions

There is a major misunderstanding about what modern regular expression implementation can or cannot do. This article analyses the situation by walking through the different grammar classes.

Understanding PHP's internal array implementation (PHP's Source Code for PHP Developers - Part 4)

The fourth part of the "PHP's Source Code for PHP Developers" series, covering how arrays are internally implemented in PHP and how they are used in the source code.

PHP's Source Code for PHP Developers - Part 3 - Variables

Cross-link to the third part of the "PHP's Source Code for PHP Developers" series, covering how PHP values are represented internally and used throughout the source code.

Understanding PHP's internal function definitions (PHP's Source Code for PHP Developers - Part 2)

The second part of the "PHP's Source Code for PHP Developers" series, covering how to find functions in the PHP source code and how they are structured.

Scalar type hinting is harder than you think

A quick overview of the different scalar type hinting proposals and why PHP is having such a hard time deciding.

Pointer magic for efficient dynamic value representations

JS implementations use some neat tricks to achieve good performance. One of those tricks is a good bit of pointer magic to make dynamically typed values more efficient.

htmlspecialchars() improvements in PHP 5.4

There is some nice new stuff for htmlspecialchars() in PHP 5.4, which hasn't yet got the attention it deserves.

Careful: XDebug can skew your performance numbers

In some cases XDebug can significantly skew your benchmarking and profiling numbers. So make sure that you do measurements without it.

Disproving the Single Quotes Performance Myth

One of the oldest myths around PHP is that single quotes are faster than double quotes. And. It. Is. Not. True.

Supercolliding a PHP array

Inserting 65536 specially crafted values into a PHP array can take 30 seconds, whereas normally it would only take 0.01 seconds.

Don't be STUPID: GRASP SOLID!

Introducing STUPID: Singleton, Tight Coupling, Untestability, Premature Optimization, Indescriptive Naming, Duplication.

How big are PHP arrays (and values) really? (Hint: BIG!)

PHP's memory usage might seem atrocious to some - twenty times more than the optimum you would have in C. This post tries to explain those numbers and why they are necessary.

PCRE and newlines

There is a huge number of newline related features in PCRE (regular expressions) that nearly nobody knows about. I want to shed light on some of those.

Manually installing PEAR on Windows

If you ever tried to install PEAR on Windows you probably know what a woeful task it is. This is a short instruction on how to manually install PEAR (without using go-pear.phar).

PHP internals: When does foreach copy?

PHP's foreach language construct sometimes copies the array it iterates and sometimes does not. This post analyzes when and why this happens.

Improving lexing performance in PHP

Some thoughts on improving lexing performance in PHP by compiling the individual token regexes into one big super-regex.