Posts filed under “php”
Install mcrypt PHP extension on OS X Snow Leopard
Please note: The following instructions apply to Mac OS X 10.6 (Snow Leopard). I have an updated guide for how to install mcrypt on 10.7 (Lion). mcrypt is a useful extension to PHP if you would like to support a wide range of encryption algorithms within your code. This guide explains how you can enable [...]
Normalize URL's with PHP
I've posted to GitHub a PHP class that I've written which can handle URL normalization, as specified by RFC 3986. https://github.com/glenscott/url-normalizer Specifically, the following normalization steps are performed: Normalize case Decode unreserved characters Remove dot segments An example of use:
Install memcached PHP extension on OS X Snow Leopard
memcached is a very useful memory object caching system, which can be used to increase the performance of your dynamic scripts by caching database calls. This guide will explain how to install the memcached system, including the PHP extension, on Mac OS X 10.6. Xcode The Xcode package installs the necessary versions of tools like [...]
Fix PHP timezone warnings in OS X Snow Leopard
The standard Mac install of PHP has always been somewhat quirky, and 10.6 is no exception. One of the most obvious issues occurs when attempting to use date/time functions. PHP 5.3 requires that the date.timezone setting is available. Without this, you will receive a warning similar to the following: Warning: getdate() [function.getdate]: It is not [...]
PHP 5.3: The Good, the Bad and the Ugly
PHP 5.3 was released today; here are my positive and negatives: The Good: Closures Anonymous functions created with create_function have always been a bit messy. With 5.3 comes support for closures with a much cleaner syntax: $greet = function($name) { printf("Hello %s\r\n", $name); }; $greet('World'); $greet('PHP'); The Bad: Backwards incompatible changes Although not a massive [...]
mcrypt support for PHP on 64 bit Mac OS X 10.5
Please note: The article below refers to installing mcrypt on Mac OS X 10.5. If you have 10.6 Snow Leopard, please see my updated guide: Install mcrypt PHP extension on OS X Snow Leopard Adding additional functionality to the standard Apple-supplied PHP on Mac OS X 10.5 is a little tricky if you are running [...]
PHP Best Practices #2: Strictures
Make sure PHP is reporting all errors and warnings. Warnings and notices are PHP's way of letting you know that you are utilising features in a non-standard way. If your code is omitting errors, then it should be fixed as soon as possible. Strict warnings are a class of errors that are turned off by [...]
PHP Best Practices #1: Regular expressions
preg not ereg This is the first in what I hope will be a regular series of posts on PHP best practices, inspired in part by Damian Conway's Perl Best Practices book. Historically, PHP has had two incompatible regular expression engines available, POSIX Extended and PCRE (Perl Compatible Regular Expressions). Arguably, Perl-compatible regular expressions are [...]
PhpDocumentor in 5 minutes
Introduction This is a quick and dirty guide to the absolute minimum you need to get up and running with PhpDocumentor. One of the slightly off-putting aspects of PhpDocumentor is the amount of tags (`@`) that are available, which can initially be overwhelming. e.g. see PEAR example: PEAR sample file This guide shows you the [...]
Closures in PHP 5.3
A good article from IBM's developerWorks on the new functional programming features in the upcoming release of PHP 5.3: What's new in PHP V5.3, Part 2: Closures and lambda functions