PHP - Setup
PHP is an
open-source,
server side scripting language for creating Web pages using resources
available at a server, often a database.
UMUC has set up PHP, version 4, in a secure environment on the Nova
server. In order to access the program certain precursor preparation
is necessary. At UMUC, PHP is run using a program, cgiwrap. here is
the drill:
- Create a directory called cgi-bin as a child of your Nova www
directory. For example:
~<home_directory>/www/cgi-bin/
All PHP scripts must be placed in this cgi-bin directory or in a child of this directory.
- Set the permissions for the cgi-bin directory and all included
subdirectories and scripts to chmod 700.
- Include '#!/usr/local/bin/php' as first line of all PHP scripts
or HTML coded pages that include PHP scripts.
- Use the format:
http://nova.umuc.edu/cgi-bin/cgiwrap/user_name/<subdirectory_if_ any>/<file_name.php>
to call a PHP file, or a HTML coded file that contains PHP code (which then becomes a PHP file.)
A sample HTML coded page that includes PHP code:
The 'live' link:
HTML file with included PHP code
The code:
#!/usr/local/bin/php
<!-- TDay.php, ffl, 9/20/03 -->
<html>
<head>
<title>Date/Time Listing PHP Script</title>
</head>
<body>
<h5>Date/Time Listing PHP Script</h5>
<?php
echo "According to this server today is: <br>";
$today = date("l dS of F Y h:i:s A");
print "$today";
?>
</body>
</html>
Note: More than you want to know about
PHP date codes can be found here.
A sample PHP coded page that writes the HTML:
The live link:
A PHP file that writes the html
The code:
#!/usr/local/bin/php
<?php
//Sum_01.php, ffl, 9/20/03
echo "<html>
<head>
<title>Simple PHP code</title>
</head>
<body>
Just a few lines of PHP code wrote this HTML<br>
page as well as doing a bit of arithmatic.
<br><br>
1.254 + 3.683 = ";
$sumIt=1.254+3.683;
print "$sumIt";
echo "
<br><br>
</body>
</html>"
?>
Note: The PHP echo and print commands are interchangeable.
Return to Top Index
Return to PHP Index