Here is a simple function to check an array to see if it contains all null values. function allNulls($arr) { if(is_array($arr) && count(array_diff($arr, array(null))) == 0) { return true; } return false; } echo (allNulls(array(null,null,null)) ? "true" : "false") . PHP_EOL; echo (allNulls(array(null,1,null)) ? "true" : "false") . PHP_EOL; echo […]
php
While developing apps that use external web services, a proxy often comes in handy in order to bypass the pesky XSS security settings found in most browsers. Here is a simple PHP proxy I’ve found quite helpful.
Simple PHP Proxy
Here is a handy function for reading a file line by line in reverse (from the end of the file). function rfgets($handle) { $line = null; $n = 0; if ($handle) { $line = ''; $started = false; $gotline = false; while (!$gotline) { if (ftell($handle) == 0) { fseek($handle, […]
Reading a file line by line in reverse with PHP
While developing a testing framework I decided it would be nice to use a random sample of records from Alexa’s Top 1 million domains list. Here is the function I wrote to read a random number of lines from the file. function random_lines($filename, $numlines, $unique=true) { if (!file_exists($filename) || !is_readable($filename)) […]
Reading random lines from a file with PHP

While working with SSL certificate based authentication I developed a handy tool to display the contents of certificates. Both PKCS12 .p12 certificates (commonly used for client authentication) as well as standard public .cer certificates. Here is my utility to check certificate information. And if you are looking for a couple […]
Certificate Information Extractor
One view of object-oriented programming is that it is a discipline that enforces modularity and clean interfaces. A second view emphasizes encapsulation, the fact that one cannot see, much less design, the inner structure of the pieces. Another view emphasizes inheritance, with its concomitant hierarchical structure of classes, with virtual functions. Yet another view […]
Fred Brooks on the promise of object oriented programming
Most websites employ a simple authentication mechanism generally consisting of a username and a password. While this method is certainly acceptable and secure for most applications, I want to take a minute to explore a more complex and, if employed correctly, more secure method of authenticating a user to a […]
Secure client authentication with php-cert-auth
I’ve been working on a rather large web application which is responsible for combining data from a variety of sources and presenting the data to the end user in a clean, unified fashion. During this process we sometimes run into cases where multiple related calls are made, each to perform […]
Process forking and threading with PHP
I ran into a situation recently where I had a very large array object that was not going to change. It was the polygon coordinates for the world countries to be used in KML provided by Thematic Mapping. I didn’t wan’t to pull this data out of MySQL every time […]
Using PHP to write PHP
Earlier this year Facebook developers caused quite a stir in the PHP community by releasing HipHop, the central piece in their high-performance arsenal. Here is the video of the initial announcement along with some juicy technical details: If you are interested in seeing how your PHP project fares when run […]