Web Development Tutorials for August 2011

PHP Random - Generate random Numbers and Strings

PHP random numbers and strings are easily generated using the PHP rand function. This function can be made to generate pseudo-random numbers within certain boundaries based on the arguments passed to it. Have a look at our PHP random tutorial below.

Note: We might use the term "random" throughout this tutorial, but kindly note that what the 'rand' function generates is pseudo-random numbers.

PHP Mail Function - Sending E-mail with PHP

The PHP mail function is what we use if we want to send email using a PHP script. This function is appropriately named mail, and when invoked with the right parameters, it allows us to send an email fairly easily.

For the PHP mail function to work properly, PHP itself must be configured to use a mail transfer agent. We will look more at that below. Right now let's get into the syntax of the PHP mail function.

The syntax for the simplest form of the PHP mail function is as follows:


PHP delete directory recursively

In this PHP tutorial, we will learn how to use PHP to delete a directory and any files which may be contained in the directory. The rmdir command is used to tell PHP to remove a directory, but this only works on empty directories. If we want to remove a directory which contains subdirectories (or subfolders if you like) and files in these subdirectories we need to write our own function which gets a bit more involved.