Library tutorials & articles
An Introduction to PHP
Server Variables
All servers maintain a set of variables that provide information such as where
the user come from, and other useful information. You can access these variables
by name in PHP. For example, if you wanted to know the link that the user clicked
to get to the current page, you could use the $_SERVER["HTTP_REFERER"] server
variable.
The following example lists the referer, and the visitor's browser.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Server Variables</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<p>
<?php
print "Referer: " . $_SERVER["HTTP_REFERER"] . "<br>";
print "Browser: " . $_SERVER["HTTP_USER_AGENT"]. "<br>";
?>
</p>
</body>
</html>
List of Server Variables
The $_SERVER array stores all of the server variables that can be accessed.
The $_SERVER variable is an associative array that you could iterate using the
foreach construct. The following example lists each of the variables, and the
associated value.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>List of Server Variables</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>List of Server Variables</h1>
<p>
<?php
foreach($_SERVER as $key=>$value)
print $key . " = " . $value . "<br>";
?>
</p>
</body>
</html>
Related articles
Related discussion
-
Create this kind of website
by maidentv (1 replies)
-
PHP London July Meetup
by webdeveloperit (1 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
SOFTWARE PHP WORK
by synctel (0 replies)
-
London PHP / MySQL Superstar needed!
by gatewaytechnolabs (1 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Dec
3
The Auckland PHP December meetup
Auckland, New Zealand
Topic: Magento E-Commerce platform Speaker: Robert Popovic, LERO9, Robert is the Technical Director and co-founder of LERO9. Robert attended the Electrotechnical Faculty at The University of Belgrade where he graduated with a Masters in Computer Science and Information Technology. Robert has worked exclusively in the field of web and software development throughout his career.
It is not just talk though: Zend server is flourishing despite the recession - "the Q1 of 2009 has been our strongest quarter ever," says Suraski - and although PHP's enterprise market share is small compared to Java or .NET, it is growing. Read more on ITJOBLOG.
!--removed tag-->but i need to send values in one folder to another
Yes, I think you're correct, although you could easily have a line like this:
to get around that problem. Which I think is what's missing from this tutorial
In the PHP file should it be "$_POST["num"]" ?
instead of just $num?
I have in php a header which brings a save as box , but when file is down loaded it contains the 6 blank spaces at the start of of document .
I have to avoid storing these blank spaces.Please help me to solve this problem.
You can also do string concatenation like
$h = "Hello";
$w = "World";
$message = "$h $w";
This thread is for discussions of An Introduction to PHP.