How to write a random quote on a page

Here is a simple but useful piece of PHP code.

Edit the following code to add your favorite quotes and then save it as “quotes.php”.

< ?php
$quotes = array(
'Quote phrase one',
'Quote phrase one',
'Quote phrase one',
'Last Quote phrase' );
shuffle($quotes);
echo $quotes[0];
?>

All you need to do now is to add this piece of code in the place where you want to write the random quote.

Example:

<p class="quote">
< ?php include('quotes.php'); ?>
</p>


Simple but usefull for many people out there…

by Humberto

Leave a Reply

You must be logged in to post a comment.