Tag Archives: PHP

Work Queues – Gearman

These are the slides from the Gearman work queue talk at CI Conf in San Francisco yesterday. Gearman and CodeIgniter from Erik Giberti

Posted in : uncategorized | Tagged : , , , , | 1 Comment

Reading the Twitter Stream API with PHP

Monitoring a term like ‘Facebook’ with the Twitter Search API can result in hundreds of tweets every minute. If you continuously issue requests for the next set of data, you’ll eventually get a message that reads, “You have been rate … Continue reading

Posted in : PHP | Tagged : , , | 18 Comments

PHP’s Eval() is Evil

A clients server was recently compromised because of a bug in an old software package that allowed writing to the filesystem. During the normal execution of the app, the code inserted itself into other files until nearly all .php files … Continue reading

Posted in : PHP, Security | Tagged : , | Comments Off on PHP’s Eval() is Evil

Validating Credit Card Numbers

The easiest way to pre-verify a credit card value is entered correctly is to use the Luhn algorithm to check for mistakes. This is commonly referred to as a mod-10, mod10 or mod 10 check. It’s always important when handling … Continue reading

Posted in : jQuery, PHP | Tagged : , , , | Comments Off on Validating Credit Card Numbers

Escaping Unicode Characters to HTML Entities in PHP

This is a severe hack I used to get around some character translation issues encountered with non-latin character sets. You should at all costs use a character set that supports international characters whenever possible, probably UTF-8 if your application language … Continue reading

Posted in : PHP | Tagged : , , , | 7 Comments

Working with Big Integers in PHP

This is the start of a class I developed for working with URL shortening and doing math with large numbers such as Facebook User Ids. There are some issues with the implementation of base convert, but if you are going … Continue reading

Posted in : PHP | Tagged : , | Comments Off on Working with Big Integers in PHP

Simple File Based Caching in PHP

Depending on the access pattern for the your data, file based caches are often more economical, despite being slower, than an in memory cache like Memcached or APC. Disk space is cheap and is therefore a good option for caching … Continue reading

Posted in : PHP | Tagged : , , , , , | 2 Comments

Remove an Array Element

Edit: An astute reader pointed out I am doing a bunch of work for nothing! PHP’s built in array_splice() is actually the tool I was looking for. If you only skim the documentation you’ll miss this additional way the function … Continue reading

Posted in : PHP | Tagged : , | 1 Comment

Double Decode MIME Attachments

While working on a project to parse emails, I found that binary attachments require double decoding to get back to binary formats. I was surprised to find a general lack of usable pre-built classes for handling or parsing email attachments, … Continue reading

Posted in : PHP | Tagged : , , , | Comments Off on Double Decode MIME Attachments

De Duping an Array in PHP the Easy Way

This is a quick and dirty way to clean up the values in an array, removing duplicates while preserving (as much as possible) the original order of the values. This method works well for smaller sorted data sets, having less … Continue reading

Posted in : code, PHP | Tagged : , , , | 1 Comment