Archive for the ‘Curiosities’ Category

What’s new in PHP 5.4? A huge list of major changes!

Tuesday, September 27th, 2011

The PHP 5.4 is now available.

As you probably know, the updates that were intended for postponed PHP 6 were added to PHP 5.4.0 instead, so now PHP includes a huge set of new language features and removes several legacy behaviors.

Because of that I created a list of major changes since PHP 5.3 ,along with some examples and brief descriptions of these changes… (more…)

Ani-Shell, just another black-hat shell in PHP

Tuesday, September 27th, 2011

Quoting the project’s home page:

Ani-Shell is a simple PHP shell with some unique features like Mass Mailer , A simple Web-Server Fuzzer , a DDoser etc! This shell has immense capabilities and have been written with some coding standards in mind for better editing and customization


The Plot to Kill PHP MySQL Extension

Friday, July 15th, 2011

Today I received a mass email from This was an information about a new entry on a blog led by Manuel Lemos, the creator of the site.

In this entry he informs us that the PHP core developers are planning to kill the PHP original MySQL extension. (more…)

phpMultiServer, a high-performance HTTP server written in pure PHP

Tuesday, June 14th, 2011

This is a sample, high-performance HTTP server written in pure PHP.

Thanks to various optimizations, this server is able to handle more than 800 HTTP requests/second on a dual core laptop (Core 2 Duo 1.6Ghz).

This in turn allows you to create highly efficient PHP scripts with low response times (less than 1ms latency between sending request to launching PHP script).

In result this software is sometimes faster than the Apache HTTP Server (which is written in highly efficient C language). (more…)

Eval() counterparts in PHP: how to do something wrong faster?

Monday, June 13th, 2011

Probably all PHP developers know what is the eval() command, and why it should be avoided.

There are several reasons, but mainly the problem is the safety and efficiency of the script. An additional disadvantage may be lack of support by the compilers of PHP code (for example, HipHop for PHP).

Unfortunately, there are situations where it is necessary to execute dynamically created code. In this article I will focus on performance and faster replacement of eval() command. (more…)

Download VMware image of Fedora 14 Linux with HipHop for PHP installed

Friday, June 10th, 2011

Many articles on this blog describes the performance and functionality of HipHop. Since many readers like the dry facts, I decided that I prepare an image of Linux distribution, which will have a built-in support to PHP code translator. (more…)

Drupal 7: HipHop for PHP vs APC – benchmark

Tuesday, May 17th, 2011

Drupal is one of two most popular content management systems (CMS) written in PHP . It is used as a back-end system for at least 1.5% of all websites worldwide. It is also one with the the slowest systems of this kind on the Internet

There have been many suggestions on improving Drupal performance, some of them recommend the use of APC module, data caching, or even compilation of the entire system through HipHop for PHP. While the first two solutions have been successfully implemented, no one was able to perform the build process.

After many battles with the compiler and the Drupal code, I present you results of the first successful translation of Drupal 7 to C++ language. (more…)

Object-Oriented PHP: Implementation of C# getters and setters in PHP

Friday, May 13th, 2011

PHP 5 and C# .NET have a getter and setter method feature, making it look like we’re accessing the data member directly. As you probably know, in C# you can define getters and setters for the properties of an object like this:

public class Person
    //default constructor 
    public Person()
    private string _Name;
    public string Name
        //set the person name
        set { this._Name = value; }
        //get the person name 
        get { return this._Name; }

You can simulate this functionality in PHP 5.x using the magic __get () and __set () functions, but that solution has one big drawback. Magic variables are not visible in the PHP code (in a class declaration), and in IDE applications (until the variable is declared “virtually” from the phpDoc comments).

Because of that I present you another little-known functionality of the PHP language, which solves the above problems. In my solution you can easily convert class properties into magic variables which will be visible everywhere in the code/IDE applications. (more…)

Code injection – a simple PHP virus carried in a JPEG image

Friday, May 13th, 2011

As a developer and administrator for the webhosting company I saw many galleries and download scripts written in PHP. While the scripts were generally similar (used file_get_contents(), fopen(), readfile()), sometimes I’ve seen other, less traditional implementations.

A case of one of my company’s customers inspired me to write this article. Few months ago he reported to me with the problem of sending files via a PHP script. Some of his files were sent successfully but others did not and he could not get to the heart of the matter.

After a brief code inspection, it turned out that script written by him had some undesired, additional functionality. Because he’s been using include() clause to read an images, his script was vulnerable to the code injection! (more…)

HipHop for PHP: Unimplemented functions and features

Tuesday, May 10th, 2011

Because of various incompatibilities and installation difficulties HipHop for PHP is not the right solution for everyone deploying PHP.

In this article I present you the documentation about unimplemented functions in HipHop for PHP compiler. This is an enhanced copy of the github’s documentation which has been deleted from project’s website three days ago by unknown reason.

The article has been enhanced with my own notes to make it up-to-date and more friendly for the end-users. (more…)

How to speed up the compilation of PHP code in HipHop for PHP – part I: ccache

Tuesday, May 10th, 2011

Compilation of any program written in PHP, depending on its size, can take anywhere from few to tens of minutes.

The long compile time is nothing unusual for C, C++ and Java developers. Unfortunately the same can not be said for PHP programmers who are accustomed to the fact that all changes in the source code are seen online in their browsers.

In this article I’ll present you one of the solutions that significantly reduces the compile time of PHP code. (more…)

Drupal 7 and HipHop for PHP: compilation

Monday, May 9th, 2011

Shortly after the release of HipHop for PHP, many articles about its possibilities and functions it can offer to existing PHP scripts appeared on the internet, but the most of them described problems which disrupted the compilation process of two popular CMS systems: Drupal and Joomla. They were caused by the poor quality of the PHP code in which these systems were written.

These articles are outdated since the release of new versions: Drupal 7 and Joomla 1.6.

Has the quality of PHP code improved? Is it now possible to compile the Drupal system without any problems?
This series of articles will answer these questions.

Mod_rewrite and HipHop for PHP on Apache Web Server

Monday, April 25th, 2011

PHP scripts compiled with HipHop for PHP compiler can easily act as HTTP servers. However, they do not provide the Internet’s most popular method for creating friendly URLs’, the mod_rewrite module that is supplied with the Apache Web server.

In this article I will describe the easiest way to run compiled PHP scripts from the Apache server. (more…)