How to execute a
PHP program (script)
as an ordinary program
Stand-alone execution:
UNIX-prompt>> php PHP-program
(Must be run on holland.mathcs.emory.edu !!!)
Example:
PHP scriptluckyNum.php in
the directory
/home/cs377001/public_html/intro
<html>
<head>
<title> PHP Test </title>
</head>
<body>
<UL>
Welcome stranger, here is your lucky number:
<?php
print rand(1, 1000); # Print random number between 1 and 1000
?>
</UL>
</body>
</html>
I will demo
it in class:
Preparation:
1. ssh -X cs377001@holland
Run:
php /home/cs377001/public_html/intro/luckyNum.php
Output:
<html>
<head>
<title> PHP Test </title>
</head>
<body>
<UL>
Welcome stranger, here is your lucky number: 689
</UL>
</body>
</html>
Run again
to see a different random number
How to execute a
PHP program (script)
using a web browser
To make the web browser execute
a PHP script:
Put the PHP script/programmyPHPprog.php inside
~/public_html on
holland.mathcs.emory.edu