Recent Blog Posts
Create CSV file in memory PHP
Februar 9th, 2014 Read more ...
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 ...
Disable autoloading and enable it again later
Juli 17th, 2013 Read more ...
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:
Iterative algorithm to remove a directory tree
Juli 11th, 2013 Read more ...
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 ...
What’s the best (most efficient) way to search for content in a file and change it with PHP?
Juni 4th, 2013 Read more ...
Interesting question that is about to deleted on stackoverflow.
PHP IPC Signal Example
Mai 24th, 2013 Read more ...
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:
Dump Source Code of Closure in PHP
Mai 22nd, 2013 Read more ...
Recently I was required to dump the source code of a closure in php, for debugging purposes. Here comes my first working approach:
Simple download / upload speed measurement with PHP
Januar 29th, 2013 Read more ...
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 ...
Remove all packages from a pear channel
Dezember 20th, 2012 Read more ...
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
PHP script for validating a XML file against a XSD Schema
Oktober 10th, 2011 Read more ...
A simple script that shows how to validate xml against in xsd schemas using PHP.
printf like log function for PHP
Oktober 9th, 2011 Read more ...
The following functions are good friends for logging. You can use format strings parsed by printf and several log levels.
Hexdump function for PHP
April 30th, 2011 Read more ...
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.
doctrine 1.2.x – autoload model classes
Januar 31st, 2010 Read more ...
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.