Archive for May, 2006
Its quite common for people to enter in their URL when signing up - but what if you want to verify that this is a real page? You can validate the URL using a regular expression up to a point, but all that tells us is that the URL is well formed. What I wanted to do was to check that the page exists - i.e. that we don't get a 404 for it.
Luckily, this is quite easy if you have the Curl extension installed.
Continue Reading May 31st, 2006
A common practice at the moment is to shorten affiliate links into a more useable format. For example, I have an affiliate link for 123-reg.co.uk which is http://www.123-reg.co.uk/affiliate.cgi?id=AF106554. However, if I want to share that link with someone, I have to login to my control panel, and get the link. It would be a lot nicer if I could offer a more memorable link like ukdomains.jellyandcustard.com.
This is in fact very easy to set up, however for those of you on shared hosts (without access to httpd.conf) your host will need to aid you in one or two steps.Here's how I did it:
May 24th, 2006
During the days of PHP4, the most common way of showing the files in a directory was like so:
PHP:
-
if ($handle =
opendir('/home/fernando/temp')) {
-
while (false !==
($file =
readdir($handle))) {
-
if ($file != "." && $file != "..") {
-
-
}
-
}
-
-
}
However, if your PHP version has now been upgraded to PHP 5, you can take advantage of DirectoryIterator instead. This class (don't get scared) is part of the SPL library that is now bundled within PHP 5.
May 18th, 2006
PEAR, the PHP Extension and Application Repository, has been around since 1999, and has several functions. According to the 'About PEAR' page:
The purpose of PEAR is to provide:
- A structured library of open-sourced code for PHP users
- A system for code distribution and package maintenance
- A standard style for code written in PHP
- The PHP Extension Community Library (PECL)
- A web site, mailing lists and download mirrors to support the PHP/PEAR community
Getting Started
For most PHP coders, including myself at one point, PEAR seemed to be a bit of a mystery for those who shy away from object orientated programming. The first point to remember is this: you don't need OOP knowledge to use PEAR! Yup, no lies, you can use it if you have an ounce of intelligence, and can read the documentation! So, to calm the fear of PEAR, I'm going to take a step by step approach to installation, and the usage of several PEAR classes in a series of posts.
Continue Reading May 10th, 2006
A critical bug with $_POST array handling as well as the FastCGI sapi have been discovered in PHP 5.1.3. A new PHP release 5.1.4 is now available to address these issues. All PHP users are encouraged to upgrade to this release as soon as possible.
May 5th, 2006
After what seems like an eternity, PHP 5.1.3 has been released. Among the changes, the new release comes with improved date / time facilities, improvements to GD, CURL, SPL and a number of security fixes. More information can be found in the PHP Release Docs.
Along with this release sees a collection of PECL binaries available as a collection for Windows users. You can download PHP 5.1.3 from your closest mirror now!
May 2nd, 2006
Although not directly PHP-related, I'm aware that a lot of people who look over this blog are freelance or part time coders. It's always important to make sure that both you and your client stand on the same level, and as such, MediaSurgery have been kind enough to release their web design contract (checked by a lawyer) for free. The contract is available in both Open Office and Microsoft Word formats. Go get it!
May 2nd, 2006