Jump to content

Detecting the file name of the currently loaded page


mhoctober

Recommended Posts

All..

I'd like a .htm page to contain php script that can detect the file name of the current loaded page....

eg if a user clicks a link that loads the following page ...

www.myhost.com/12345.htm

I'd like 12345.htm to contain code that is able to extract the /12345.htm for storeage in a table or echo to the screen etc....

I have been playing around with

<?php
$url1=$_SERVER['REQUEST_URI'];
echo $url1;
?>

which works fine but when I attempt to encapsulate this in html and save and then load it as a .htm file the only output I get is "This is a test file"

<html>
<body>
This is a test file
<?php
$url1=$_SERVER['REQUEST_URI'];
echo $url1;
?>
</body>
</html>

Am I missing something simple!!!??
Make sure that .htm is set as a php extension for IIS or Apache, depending on what your using. Normally .php is set as a php script, and the other extensions will be treated as ordinary html (.htm, .html). Other exetention that can be set include .cfm for coldfusion, .asp for asp, and so on and so forth.

Basically it's in the configuration of your server.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.