Jump to content


Photo

Detecting the file name of the currently loaded page


  • Please log in to reply
1 reply to this topic

#1 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 18 March 2006 - 08:00 PM

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!!!??

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 18 March 2006 - 08:38 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users