Recent Blog Posts

I've often seen solutions which are creating a temporary file using `tempnam()`. However, this solution still needs all contents written to a file first and then, in a second step, reading again using `file_get_contents()`. Also it needs to be sure that the file will be removed after operations, ... I mean *ensured*! ;) Here I will show an alternative ...
For some reasons it might be useful to disable autoloading, do some stuff and enable it again later. When using some frameworks or libraries this should be done in an anonymous way. For that pupose PHP provides the following functions:
When it comes to deleting a directory tree most solutions that have been posted around are recursive functions, like the following: ... While this is easy to implement it has some disadvantages when it comes to large trees ...
Interesting question that is about to deleted on stackoverflow.
There are several pitfalls when using POSIX signal handling with php. The following example should help to get around them. The example forks a child process and afterwards sends the `SIGTERM` signal to the child. I'll guide you through the important sections:
Recently I was required to dump the source code of a closure in php, for debugging purposes. Here comes my first working approach:
I was requested on stackoverflow to give a little download measurement script in PHP. Below the displayed page an info about download size and download speed should be displayed. I found the question really interesting. Here comes a short example how I would do this ...

The PEAR installer has no option to remove all packages from a channel at once. So I’ve crafted a small shell script for that task:

#!/bin/bash
CHANNEL_NAME="THE NAME"

for pkg in $(pear list -c "$CHANNEL_NAME"  \
| awk '{if ( $2 ~ /([0-9]+)\.([0-9]+)\.([0-9]+)/ ) print $1}') ; do 
    pear uninstall "$CHANNEL_NAME/$pkg"
done
A simple script that shows how to validate xml against in xsd schemas using PHP.
The following functions are good friends for logging. You can use format strings parsed by printf and several log levels.
When devoloping PHP applications that handle binary data it is useful to to be able to hexdump that data for debugging or logging. This is a hexdump() implementation for PHP.
While playing a bit with Doctrine ORM (1.2.1) for PHP, I encountered problems with autoloading my model classes. The autoload mechanism is described here. But as far as I see they changed this behaviour in doctrine 1.2.x but they didn't updated the documentation yet. So it took me a while to find a solution. Here are the steps to reproduce the problem and my solution for this. I have simplified the original steps from the doctrine documentation a bit.