Page 18 - Open Soource Technologies 304.indd
P. 18
Web Technologies-I
Notes Save the configuration file and test it from the command line (Start > Run > cmd):
1. cd \Apache2\bin
2. httpd -t
Step 5: Test a PHP file
Create a file named index.php in Apacheís web page root (either htdocs or D:\WebPages) and
add this code:
<?php phpinfo(); ?>
Ensure Apache has started successfully, open a web browser and enter the address http://localhost/.
If all goes well, a “PHP version” page should appear showing all the configuration settings.
1.4 A Walk through PHP
PHP pages are HTML pages with PHP commands embedded in them. This is in contrast to
many other dynamic web-page solutions, which are scripts that generate HTML. The web server
processes the PHP commands and sends their output (and any HTML from the file) to the browser.
Example shows a complete PHP page.
hello.php
<html>
<head>
<title>Look Out World</title>
</head>
<body>
<?php
echo ‘Hello, world!’
?>
</body>
</html>
Save the contents of the example to a file, hello.php, and point your browser to it. The results
appear in Figure 1.6.
Figure 1.6: Output of hello.php
The PHP echo command produces output (the string “Hello, world!”), which is inserted into the
HTML file. In this example, the PHP code is placed between <? php and?> tags.
12 LOVELY PROFESSIONAL UNIVERSITY