phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Basic: Variable from the outside PHP

Tag: data type, variable, outside   Category: PHP Basic
post: 01 Mar 2008 read: 94


PHP Basic Data Type Step By Step Tutorial - Part 14:Variable from the outside PHP is also often referred to as web server variable. Variable of server web will contain the data that is related to the server web and operating server web system.

PHP_SELF variable is used for many times to automate a link which relate each other. Beneath, there are a number of variables of server web which often required and used:

- DOCUMENT_ROOTcontain of name document directory of web
- PHP_SELF contain of information name of accessed script.
- HTTP_USER_AGENT contain of information used browser.
- REMOTE_ADDR contain of address information of IP visitor.
- SERVER_NAME contain of name of server.
- SERVER_SOFTWARE contain of name used by software server web.
- SERVER_PORT containing of port number information used for connection to web server.
- SERVER_PROTOCOL which express the name of protocol.
- REQUEST_METHOD containing of information of method request - GET or POST.

Pay attention to the example of using PHP variable as following:
File name: phpself.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
	print ("Your directory script : ".
        $DOCUMENT_ROOT."<br>");
	print ("Your script : ".$PHP_SELF."<br>");
	print ("Your browser : ".$HTTP_SERVER_VARS['HTTP_USER_AGENT']."<br>");
	print ("Your IP : ".$HTTP_SERVER_VARS['REMOTE_ADDR']."<br>");
	print ("Your server name : ".$HTTP_SERVER_VARS['SERVER_NAME']."<br>");
	print ("Your server web name : ".$HTTP_SERVER_VARS['SERVER_SOFTWARE']."<br>");
	print ("Your port server : ".$HTTP_SERVER_VARS['SERVER_PORT']."<br>");
	print ("Your protocol : ".$HTTP_SERVER_VARS['SERVER_PROTOCOL']."<br>");
?>
</body>
</html>
php basic - phpself



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting