------HTTP Response------>
[kal@oracle classexamples]$ lynx -mime_header
HTTP/1.1 301 Moved Permanently
Date: Fri, 21 Feb 2003 10:46:44 GMT
Server: Apache/1.3.19 (Unix) (SuSE/Linux) PHP/4.1.2 mod_ssl/2.8.3 OpenSSL/0.9.6a
Location:
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML<HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD<BODY>
<H1>Moved Permanently</H1>
The document has moved <A HREF="
<HR>
<ADDRESS>Apache/1.3.19 Server at Port 80</ADDRESS>
</BODY</HTML>
------env.txt------>
[kal@oracle classexamples]$ more env.txt
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print <EndOfHTML;
<html<head<title>Print Environment</title</head>
<body>
EndOfHTML
foreach $key (sort(keys %ENV)) {
print "$key = $ENV{$key}<br>\n";
}
print "</body</html>";
------
DOCUMENT_ROOT = /home/nord/
GATEWAY_INTERFACE = CGI/1.1
HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT_LANGUAGE = is
HTTP_CONNECTION = Keep-Alive
HTTP_HOST =
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
PATH = /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/java/ant/bin:/usr/local/java/j2sdk/bin:/usr/local/java/j2sdkee/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
QUERY_STRING =
REMOTE_ADDR = 130.208.143.2
REMOTE_HOST = bells.cs.hi.is
REMOTE_PORT = 1461
REQUEST_METHOD = GET
REQUEST_URI = /~kal/cgi-bin/env.cgi
SCRIPT_FILENAME = /home/kal/.public_html/cgi-bin/env.cgi
SCRIPT_NAME = /~kal/cgi-bin/env.cgi
SERVER_ADDR = 130.208.143.42
SERVER_ADMIN =
SERVER_NAME =
SERVER_PORT = 80
SERVER_PROTOCOL = HTTP/1.1
SERVER_SIGNATURE =
Apache/1.3.27 Server at Port 80
SERVER_SOFTWARE = Apache/1.3.27 (Unix) PHP/4.3.1
UNIQUE_ID = PlX-@X8AAAEAAFhiLTE
------env1.php (file)------>
[kal@oracle new]$ more env1.php
<?php
phpinfo();
?>
------ --->
(Not all of it!)
PHP Version 4.3.1
...
Apache Environment
Variable Value
DOCUMENT_ROOT /home/nord/
HTTP_ACCEPT image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE is
HTTP_CONNECTION Keep-Alive
HTTP_HOST
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/java/ant/bin:/usr/local/java/j2sdk/bin:/usr/local/java/j2sdkee/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
REMOTE_ADDR 130.208.143.2
REMOTE_HOST bells.cs.hi.is
REMOTE_PORT 1457
SCRIPT_FILENAME /home/kal/.public_html/php/new/env1.php
SERVER_ADDR 130.208.143.42
SERVER_ADMIN
SERVER_NAME
SERVER_PORT 80
SERVER_SIGNATURE <ADDRESS>Apache/1.3.27 Server at Port 80</ADDRESS>
SERVER_SOFTWARE Apache/1.3.27 (Unix) PHP/4.3.1
UNIQUE_ID PlX-tH8AAAEAAFhdJuE
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /~kal/php/new/env1.php
SCRIPT_NAME /~kal/php/new/env1.php
...
HTTP Headers Information
HTTP Request Headers
HTTP Request GET /~kal/php/new/env1.php HTTP/1.1
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Encoding gzip, deflate
Accept-Language is
Connection Keep-Alive
Host
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
HTTP Response Headers
X-Powered-By PHP/4.3.1
Keep-Alive timeout=15, max=99
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html
Environment
Variable Value
HOSTNAME oracle
PVM_RSH /usr/bin/rsh
SHELL /bin/bash
TERM xterm
HISTSIZE 1000
SSH_CLIENT 212.30.223.199 1592 22
QTDIR /usr/lib/qt3-gcc3.2
SSH_TTY /dev/pts/0
ANT_HOME /usr/local/java/ant
USER root
LS_COLORS no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
PVM_ROOT /usr/share/pvm3
USERNAME root
PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/java/ant/bin:/usr/local/java/j2sdk/bin:/usr/local/java/j2sdkee/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
MAIL /var/spool/mail/root
PWD /usr/local/apache
INPUTRC /etc/inputrc
JAVA_HOME /usr/local/java/j2sdk
J2EE_HOME /usr/local/java/j2sdkee
LANG en_US
LAMHELPFILE /etc/lam/lam-helpfile
SSH_ASKPASS /usr/libexec/openssh/gnome-ssh-askpass
HOME /root
SHLVL 2
XPVM_ROOT /usr/share/pvm3/xpvm
BASH_ENV /root/.bashrc
LOGNAME root
LESSOPEN |/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES 1
_ /usr/local/apache/bin/httpd
.....
PHP Variables
Variable Value
PHP_SELF /~kal/php/new/env1.php
_SERVER["DOCUMENT_ROOT"] /home/nord/
_SERVER["HTTP_ACCEPT"] image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
_SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate
_SERVER["HTTP_ACCEPT_LANGUAGE"] is
_SERVER["HTTP_CONNECTION"] Keep-Alive
_SERVER["HTTP_HOST"]
_SERVER["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
_SERVER["PATH"] /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/java/ant/bin:/usr/local/java/j2sdk/bin:/usr/local/java/j2sdkee/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
_SERVER["REMOTE_ADDR"] 130.208.143.2
_SERVER["REMOTE_HOST"] bells.cs.hi.is
_SERVER["REMOTE_PORT"] 1457
_SERVER["SCRIPT_FILENAME"] /home/kal/.public_html/php/new/env1.php
_SERVER["SERVER_ADDR"] 130.208.143.42
_SERVER["SERVER_ADMIN"]
_SERVER["SERVER_NAME"]
_SERVER["SERVER_PORT"] 80
_SERVER["SERVER_SIGNATURE"] <ADDRESS>Apache/1.3.27 Server at Port 80</ADDRESS>
_SERVER["SERVER_SOFTWARE"] Apache/1.3.27 (Unix) PHP/4.3.1
_SERVER["UNIQUE_ID"] PlX-tH8AAAEAAFhdJuE
_SERVER["GATEWAY_INTERFACE"] CGI/1.1
_SERVER["SERVER_PROTOCOL"] HTTP/1.1
_SERVER["REQUEST_METHOD"] GET
_SERVER["QUERY_STRING"] no value
_SERVER["REQUEST_URI"] /~kal/php/new/env1.php
_SERVER["SCRIPT_NAME"] /~kal/php/new/env1.php
_SERVER["PATH_TRANSLATED"] /home/kal/.public_html/php/new/env1.php
_SERVER["PHP_SELF"] /~kal/php/new/env1.php
_SERVER["argv"] Array()
_SERVER["argc"] 0
....
------env2.php file ---->
[kal@oracle new]$ more env2.php
<?php
echo "from Apache Environment <br />";
echo "The current document root is: $DOCUMENT_ROOT <br />";
echo "The HTTP Host is: $HTTP_HOST <br />";
echo "from PHP variables <br />";
echo "PHP_SELF is: $PHP_SELF<br />";
### Another way
$mine = getenv('Document_ROOT' );
echo "$mine <br />";
$mine = getenv('HTTP_HOST' );
echo "$mine <br />";
------env2.php --->
from Apache Environment
The current document root is: /home/nord/
The HTTP Host is:
from PHP variables
PHP_SELF is: /~kal/php/new/env2.php
/home/nord/
------function addOne value parameter --->
<?php
function addOne($param) {
$param++;
}
$it = 16;
echo " Value is: $it <br />";
addOne ($it);
echo "Value is: $it <br />";
?>
==>
Value is: 16
Value is: 16
------function addOne reference parameter --->
<?php
function addOne(&$param) {
$param++;
}
$it = 16;
echo " Value is: $it <br />";
addOne ($it);
echo "Value is: $it <br />";
?>
==>
Value is: 16
Value is: 17
------function addOne reference parameter --->
<?php
function addOne($param) {
$param++;
}
$it = 16;
echo " Value is: $it <br />";
addOne (&$it);
echo "Value is: $it <br />";
?>
==>
Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of addone(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /home/kal/.public_html/php/new/addone3.php on line 8
Value is: 16
Value is: 17
------session.php--->
<?php
session_start();
if (!IsSet($page_number))
$page_number = 1;
print("You have now visited $page_number");
print(" of pages <br />");
$page_number++;
session_register("page_number");
?>
----
You have now visited 1 of pages
(reload or a return to the page)
You have now visited 2 of pages
(etc.)
------form.html------>
<form name="form" method="post" action="contact_thanks.php">
<p class="bodymd">Your Name<br>
<input type="text" name="Name">
</p>
<p class="bodymd">Your Email<br>
<input type="text" name="Email">
</p>
<p class="bodymd">Comments or Questions<br>
<textarea name="Comments" rows="5" cols="40"</textarea>
</p>
<p class="bodymd">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Clear Form">
</p>
</form>
------contact_thanks.php---->
<?php
if (($Name == "") || ($Email == "") || ($Comments == ""))
{
echo "<form name=form method=post action=contact_thanks.php>";
echo "<p class=bodymd>All three fields of this form are required, I really don't think that's too much to ask...</p>";
echo "<p class=bodymd>Fill in the ones you missed, they are listed below.</p>";
}
if ($Name == "")
{
echo "<p class=bodymd>Your Name<br<input type=text name=Name</p>";
}
else
{
echo "<input type=hidden name=Name value=$Name>";
}
if ($Email == "")
{
echo "<p class=bodymd>Your Email<br<input type=text name=Email</p>";
}
else
{
echo "<input type=hidden name=Email value=$Email>";
}
if ($Comments == "")
{
echo "<p class=bodymd>Comments or Questions<br<textarea name=Comments rows=5 cols=40</textarea</p>";
}
else
{
echo "<input type=hidden name=Comments value=$Comments>";
}
if (($Name == "") || ($Email == "") || ($Comments == ""))
{
echo "<input type=submit name=Submit value=Submit>";
echo "<input type=reset name=Reset value=Clear Form>";
echo "</form>";
}
else
{
$message = "Name: $Name\nEmail: $Email\nComments: $Comments\n";
$extra = "From: $Name\r\nReply-To: $Email\r\n";
mail ("", "Website Email", $message, $extra);
echo "<p class=bodymd>Thanks for your inguiry, $Name.</p>";
echo "<p class=bodymd>A response will be sent to $Email as soon as possible.</p>";
}
?>
Reference: