PHP Variables
PHP Code Examples
[Download]   [Execute]
<!-- This part is just plain HTML. -->
<html><head><title>PHP Variables</title></head>
<body style="background-color: #EFEFFF;">
<img src="" 
	style="height: 3px; width: 100%; ">
<img src="" 
	style="float: right;">
<div style="color: #050b82; padding-top: 10px;">
<span style="font-size: 180%; font-weight: bold; ">PHP Variables</span>
	<div style="padding-top: 5pt;"><a href="../index.html"><img 
	src="" style="border: 0pt; 
	padding-right: 5pt; padding-left: 15pt; 
	vertical-align: middle;"><i>PHP Code Examples</i></a></div>
<img src="" style="height: 3px; 
	width: 100%; margin-bottom: 10pt; 
	clear: right; ">

// PHP variables always start with $.  (Unlike perl, all variables start with
// $, including aggregates.)
$fred = 17;
$barney = 3 + $fred;
$alice = "Do you know the way to San Jose?";
echo $fred, " ", $barney, " ", $alice

Turn left at Albuquerque.

<script language="php">
// This is another wayt to enter PHP.  And variable values survive between
// PHP regions.
echo '$barney has the value ', $barney, ".<br>";

<i>This is plain HTML.</i>

// There are many pre-defined variables which describe the script's 
// environment.

echo "<tr><td><b>My URL is:</b>:</td><td>http://",
	$_SERVER["SERVER_NAME"], ":", $_SERVER["SCRIPT_NAME"], "</td></tr>";
echo "<tr><td><b>Your browser is</b>:</td><td>",
	$_SERVER["HTTP_USER_AGENT"], "</td></tr>";
echo "<tr><td><b>Your IP address is</b>:</td><td>",
	$_SERVER["REMOTE_ADDR"], "</td></tr>";