faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

47 of 422 people (11%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How to get the name of the current PHP file? to print its modification date in a global footer.

Mar 15th, 2008 17:51
ha mo, Crick Dougles, Philip Olson, amal k m, Alex Dean, Kathy Dopp,


To get the the name of the current PHP filename, use the PHP_SELF 
predefined variable like so:
  echo $_SERVER['PHP_SELF'];
If inside an include (see include()), this will print the parent file 
(the file the include is included in) as opposed to the name of the 
include file itself.  If you want the includes file name, consider:
  echo __FILE__;
Where __FILE__ is a predefined constant.  It also includes the path so 
for just the filename:
  echo basename(__FILE__);
But for this question it appears you are using a footer (an include) 
and want the modification of the file that it's being included in (the 
parent file) so you want to do something like this:
  echo date ('F d Y H:i:s', filemtime($_SERVER['PHP_SELF']));
See the manual for details:
  http://www.php.net/variables.predefined
  http://www.php.net/function.filemtime
http://www.eindianweddingcards.com
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.mozmar.com
http://www.yamot.com
http://www.templatestemp.com