|
file.php
Contains normal HTML, and then PHP code mixed in, delimited as follows:
<html> <body> html code <?php php code ?> more html code |
PHP gets interpreted on server side before resulting HTML stream is returned to client.
Client can't see PHP code:
Unlike the case with Javascript, client can't see the code that generated the HTML.
PHP used for interaction with data on server (e.g. database).
var_dump($variable); print_r($variable);
http://host/prog.php?variable=valueExample:
world.php?world=w2m.TyrrellWorldParsed like this in world.php:
<html> <?PHP $qs=$_SERVER["QUERY_STRING"]; parse_str ( $qs ); // $world is now defined as whatever the value was ?> <head> <?PHP print "<title> World: $world </title> \n"; .... |
#!/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, this works for ssh login:
#!/local1/php5/bin/php
On Internet since 1987.