| 
	
 | 
 Posted by Robizzle on 10/07/05 18:17 
Well I figured it out while I was working on another php script.  I can 
best describe my problem with an examle. 
 
root/index.php 
root/php/date_modified.php 
 
Goal: have the date that index.php was modified added to the page. 
 
index.php 's contents: 
<?php 
include 'php/hitcounter.php'; 
?> 
 
date_modified 's contents: 
<?php 
$filename = 'index.php'; 
if (file_exists($filename)) { 
	echo "Page last modified: " . date ("F d Y H:i:s", 
filemtime($filename)) . " EST"; 
} 
?> 
 
Now, since date_modified is in a folder ('php') and index.php is in the 
root directory, I would have thought that $filename = 'index.php' 
should have been $filename ='../index.php', HOWEVER, since the way I am 
executing date_modified.php is by including it into index.php, I do not 
need to move up yet another directory. 
 
To see this script live you can check out 
http://www.cse.msu.edu/~meyerro3 although its nothing fancy, it just 
says the date I last modified index.php at the bottom. 
 
Anyways, now I have a new question.  Is there another way I can call a 
php script to execute other than including it's contents into my 
current document?  Ideally, I would like to be able to pass over a 
variable to date_modified saying which file to check (so I can use it 
for more than just my index page.)  I like having all my php scripts 
organized in a folder set inside root, however, using include() skews 
realative pathnames.  What if I want to include date_modified into a 
page that is located in root/archived_news/whatever.php? 
 
Lastly, and sorry for the essay-sized post, my previous problem with 
hitcounter.php has been solved.  My problem was that my index page was 
..html so none of the php was being executed.  Simply renaming it to 
..php did the trick, although I have also read that I can play around 
with some server-side settings to scan .html files as well. 
 
Cheers, 
-Rob
 
[Back to original message] 
 |