JavaScript Editor Javascript validator     Website design 



Team LiB
Previous Section Next Section

Creating the "Tip of the Day" Program

Way back at the beginning of the chapter I promised you would be able to write the "Tip of the day" program featured at the beginning of the chapter. This program requires HTML, Cascading Style Sheets, and one line of PHP code. The code shows a reasonably basic page.

<html>
<head>
<title>Tip of the day</title>
</head>

<body>
<center>

<h1>Tip of the day</h1>

<div style = "border-color:green; border-style:groove; border-width:2px">
<?
readfile("tips.txt");
?>
</div>

</center>
</body>
</html>

The page is basic HTML. It contains one div element with a custom style setting up a border around the tip of the day. Inside the div element, I added PHP code with the <? and ?> devices. This code calls one PHP function called readFile(). The readFile() command takes as an argument the name of some file. It reads the contents of that file and displays it onto the page as if it were HTML. As soon as that line of code stops executing (that is, the text in the tips.txt file has been printed to the Web browser) the ?> symbol indicates that the PHP coding is finished and the rest of the page will be typical HTML.


Team LiB
Previous Section Next Section


JavaScript Editor Javascript validator     Website design


R7