XML/PHP Question

iEthan

Member
So, I'm creating a XML-based PHP content management system. Here is the basic hierarchy of the directory.

LiteManage/
pgs/
index.xml
.htaccess
display.php
...
index.php

So, I want to create a script that will get the index.php and match it with a XML file in pgs/ (which would be index.xml). I know how to display the contents with SimpleXML, but I can't figure out how to get the url. I know you use $_GET, but what format?

Thanks,
~Ethan
 
Hi,

The $_GET array is for variables passed via the url such as index.php?variable_name1=value&variable_name2=value2.

and you get these like so;

PHP:
$myvar = $_GET['variable_name1'];

$myvar woudl now equal "value";

To get the current URL/URI you use the $_SERVER array;

PHP:
$_SERVER['REQUEST_URI']

'REQUEST_URI' The URI which was given in order to access this page; for instance, '/index.html'.

or you could use

PHP:
$_SERVER['PHP_SELF']

'PHP_SELF' The filename of the currently executing script, relative to the document root.
For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.
The __FILE__ constant contains the full path and filename of the current (i.e. included) file.
If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

PHP: $_SERVER - Manual
 
So let me get this right, you want to 1 find the current page, and 2 then look for an equivalent file in the pg directory?

Or d you just want to get the index.xml file from the pg directory if the index.php file is accessed?
 
Back
Top