1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4. <head>
5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6. <title>View A Quotation</title>
7. </head>
8. <body>
9. <?php // Script 11.3 - view_quote.php
10. /* This script displays and handles an HTML form. This script reads in a file and prints a random line from it. */
11.
12. // Read the file's contents into an array:
13. $data = file('../quotes.txt');
14.
15. // Count the number of items in the array:
16. $n = count($data);
17.
18. // Pick a random item:
19. $rand = rand(0, ($n - 1));
20.
21. // Print the quotation:
22. print '<p>' . trim($data[$rand]) . '</p>';
23.
24. ?>
25.
26. </body>
27. </html>