Rabu, 04 Mei 2011

Creating the Tip of the Day Program

Way back at the beginning of this chapter, I promised that you would be able to
write the featured Tip of the Day program. This program requires HTML, CSS, and
one line of PHP code. The code shows a reasonably basic page:<span class="fullpost">
<html>
<head>
<title>Tip of the day</title>
</head>
<body>
<center>
TRICK
TRAP
TRICK
<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 day’s tip. 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 that
file’s contents and displays them on the page as if it were HTML. As soon as that
line of code stops executing (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.</span>

Tidak ada komentar:

Posting Komentar