How fast can you type?

A fun test which is also said to be particularly conclusive about your typing abilities, as it uses a collection of the most widely used words in the English language.

95 words

Touch Typing online

Also on the same website a set of free touch typing lessons to get you started or make you better.

14 comments  

PHP Manual - Always to keep handy

One tool to always have near if you're serious about PHP programming is the PHP Manual. With the number of predefined functions in the hundreds, if not thousands, this is one programming language that you will hardly be able to completely memorize. And you don't have to.

The official documentation comes in the form of a .chm file which allows you to quickly access your needed information by either the contents, index, or the search function. The usability is further enhanced by the user contributions added periodically to the manual. This way, you are almost certain to find one or several examples of putting each function to good use.

The PHP Manual is free to download here.

0 comments  

Email validation with PHP

An important issue when handling data input from a website's visitors is validating the information the user submits, so that it complies with your specifications and needs. If, for the most part, this means setting up your own set of rules and writing code accordingly, one aspect that you can get away with by implementing an existing function is e-mail address validation.

There are quite a few of functions out there written for just this purpose, this is just one of them, that I've found to be doing the job quite nicely and thoroughly.


function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}


The most basic PHP email address validation function can give its ok on patterns such as , but problems might arise with emails such as . This function however validates these just fine.

A simple example of using the function is shown below:

if (!check_email_address($email)) {
echo "This is not a valid e-mail address!";
}
else {
echo "Valid!";
}

1 comments