PHP

Server-side scripts.



Environment and calling programs



Example



Call with arguments

PHP can be used with arguments in the URL.
This is like a CGI script with HTTP GET, like a Google search.

http://host/prog.php?variable=value
Example:
mind.php?mind=test093
Parsed like this in mind.php:


<html>

<?PHP
	
$qs=$_SERVER["QUERY_STRING"];

parse_str ( $qs );

// $mind is now defined as whatever the value was

?>

<head>

<?PHP
	 
 print "<title> Mind: $mind  </title> \n"; 

....
 



Stand-alone PHP scripts

Can use PHP as just general offline scripting language.
Can run Stand-alone PHP scripts at command-line. Something like:

#!/usr/local/bin/php 

Whatever is outside PHP is just displayed.

<?php

// echo PHP_VERSION;

 print "Name of script = $argv[0] \n"; 
 print "First command-line arg = $argv[1] \n"; 

 print "All command-line args: \n";
 print_r($argv); 
 print "\n"; 

?>

Whatever is outside PHP is just displayed.

On DCU Linux try:
#!/local1/php5/bin/php 


Search www.php.net: with Google.