PHP Beginner – Create a Random Text Generator

Overview:

When creating a website, it is often necessary to display dynamic text on the page. This text will change every time the page is loaded.

To create this solution, a database could be used. There is however another solution, it uses PHP’s built in rand() function and an array().

PHP Functions

PHP has hundreds of functions to make programming easier and more efficient. A PHP function is a built in piece of code that when called, performs a specific ‘function’, or routine, and then returns the result.

For example, the strlen() function takes in a string (a series of characters), and returns the length or how many characters that string contained. Here is how it works:


$myString = “The long day is now over!”;

// create a variable to store the length of the string

$stringLength;

// call the function, and pass the string to it

$stringLength = strlen($myString);

Read More