By using the readFile( ) command, which is a PHP function you can create a tip of the day program. To begin this program, we use basic HTML, along with CSS - Cascading Style Sheets and a line of PHP code. The PHP code uses the <? and ?> special tag and the readFile( ) command is placed inside with a filename, such as "tips.txt" as shown below, that is read and is displayed on your web page. As we demonstrated in the first program, we used notepad a plain text editor and stored the program on our web server, "C:\Wampserver2\www."
The steps to writing a PHP program are outlined below:
1. Select and click "Start."
2. Select and click "All Programs."
3. Select and click "Accessories."
4. Select and click "Notepad."
5. Type the HTML, CSS and PHP exactly as shown below.
<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">
<?php
readfile("tips.txt");
?>
</div>
</center>
</body>
</html>
6. Once you have type the entire program, Select "File," "Save As," and then go to the webroot of your server. For example, C:\Wampserver2\www. Type Filename, "tips.php," and then Select "Save."
The steps to creating a Text file to be read within the PHP program are outlined below:
1. Select and click "Start."
2. Select and click "All Programs."
3. Select and click "Accessories."
4. Select and click "Notepad."
5. Type the text exactly as shown below.
hey there, how are you?
6. Once you have typed the text, Select "File," "Save As," and then go to the webroot of your server. For example, C:\Wampserver2\www. Type Filename, "tips.txt," and then Select "Save
7. Use your browser to view the tips.php program. The steps are outlined below:
- Select and click "Start. "
- Select and click "All Programs."
- Select and click "Internet Explorer."
- Locate the Web Address Field, near the top-left of the Internet Explorer window and type in the Web address of the tips.php program, "http://localhost/tips.php," then enter. The tips.php program will be displayed.















Comments