Home > PHP Scripts > Random quote
Random quote
Description
Displays a random quote on a web page. Quotes are picked from a list that you define.
The code
<?php
/**
* Add this line of code in your page:
* <?php include "random_quote.php"; ?>
*/
$quotes[] = "This is a quote";
$quotes[] = "This is another";
$quotes[] = "quote 3";
$quotes[] = "quote 4";
$quotes[] = "quote 5";
$quotes[] = "quote 6";
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo "<p>" . $quotes[$randomquote] . "</p>";
?>
Get the code
Download the file to your computer: Click here to get the file
