Archive for the ‘php’ Category

Very Simple (Pretend) SQL Paramaters

<?php /*     Some hacked up code for Very Simple (Pretend) SQL Paramaters     — For when you don’t have PDO, or just can’t be bothered     Examples:         >>> SQL("SELECT * FROM users WHERE id=? AND name LIKE ?", 123, ‘"123\"’);         SELECT * FROM [...]

Posted by Matthew on December 10th, 2007

Filed under mysql, php, programming | No Comments »

PHP interface for the DecentUrl API

PHP version of the Python script located at http://decenturl.com/tools#api. Update: Thanks to a quick update by Ben, DecentURL now returns valid JSON, so the quote workaround is no longer needed. <?php /*     PHP interface for the DecentUrl service         by Matthew D (project-2501.net)         Based on the [...]

Posted by Matthew on November 23rd, 2007

Filed under php, programming | 1 Comment »

5 Things I hate about PHP

Articles on why PHP sucks are fairly common (PHP is a really easy target). So rather than repeat what’s already been said (lack of namespaces, function naming, and arugment positions, etc), I though I’d try and come up some more obscure ‘features’ and ‘bugs’ in PHP that I hate. create_function() //  Actually creates a new [...]

Posted by Matthew on October 30th, 2007

Filed under php, programming | No Comments »

Fun with ‘anonymous’ functions in PHP

Just some fun with anonymous functions in PHP (which are surprisingly rare due to silly syntax, and a buggy implementation) <?php     class LambdaException extends Exception {}     class Lambda     {         private static $cache;         public static function Create($functionString)         { [...]

Posted by Matthew on October 16th, 2007

Filed under php, programming | No Comments »

explodeTree

While reading a blog post by Kevin Van Zonneveld’s on converting arrays to trees in PHP, I was shocked to see his approach to the problem. To paraphrase a popular quote: Some people, when confronted with a problem, think“I know, I’ll use eval.” Now they have two problems. Below is the same function, but using [...]

Posted by Matthew on October 11th, 2007

Filed under php, programming | No Comments »

qpsmon v0.1

This is a simple script that will print the average qps (using a specidied peri0d) for one or more MySQL databases. If doesn’t have many practical uses, but it’s fun to watch when running large imports or exports. Screenshot <?php /*     qpsmon.php  v0.1     This is an (extremely) simple script that will [...]

Posted by Matthew on October 8th, 2007

Filed under mysql, php, programming | No Comments »