tags:

views:

325

answers:

2

I have a template I made that sets variables that rarely change, call my headers, calls my banner and sidebar, loads a variable which shows the individual pages, then calls the footer. In one of my headers, I want the URL of the page in the user's address bar. Is there a way to do this?

Currently:

<?php
$title = "MySite - Contacts";
include("header.php");
.
.
.
?>
A: 

It sounds like $_SERVER['REQUEST_URI'] is what you're after.

Greg
+2  A: 

The main variables you'll be intersted in is:

$_SERVER['REQUEST_URI'] Holds the path visited, e.g. /foo/bar $_SERVER['PHP_SELF'] is the path to the main PHP file (NOT the file you are in as that could be an include but the actual base file)

There are a ton of other useful variables worth remembering in $_SERVER, so either just:

print_r($_SERVER);

or just visit the doc at http://uk2.php.net/manual/en/reserved.variables.server.php

stuartloxton