Connect with Expertise | Find Experts, Get Answers, Share Insights

php displaying last modification time

dave
 
Posts: n/a
#1: Jul 17 '05
Hello,
Trying to get a php script to display when a web page was last modified.
My code is below, i'm getting a last modified date of dec. 31 1969 which is
wrong for one, and does not change if i modify the resulting file. The code
itself is in an include file, a footer file, which will be included at the
bottom of every page. Suggestions?
Thanks.
Dave.

<?

echo "This file was last modified: ";

$temp = pathinfo($PHP_SELF);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>



Till Glöggler
 
Posts: n/a
#2: Jul 17 '05

re: php displaying last modification time


dave wrote:[color=blue]
> Hello,
> Trying to get a php script to display when a web page was last modified.[/color]
[...][color=blue]
>
> <?
>
> echo "This file was last modified: ";
>
> $temp = pathinfo($PHP_SELF);[/color]

Maybe the error is here. Do you have register_globals = on?
If not, this should work for you:
$temp = pathinfo($SERVER['PHP_SELF']);
[color=blue]
>
> echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));
>
> ?>[/color]

HTH,

Till
Agelmar
 
Posts: n/a
#3: Jul 17 '05

re: php displaying last modification time


Till Glöggler wrote:[color=blue]
> dave wrote:[color=green]
>> Hello,
>> Trying to get a php script to display when a web page was last
>> modified. [...]
>>
>> <?
>>
>> echo "This file was last modified: ";
>>
>> $temp = pathinfo($PHP_SELF);[/color]
>
> Maybe the error is here. Do you have register_globals = on?
> If not, this should work for you:
> $temp = pathinfo($SERVER['PHP_SELF']);[/color]

this should be $_SERVER['PHP_SELF'] (note the underscore before SERVER)


dave
 
Posts: n/a
#4: Jul 17 '05

re: php displaying last modification time


Hello,
My thanks to everyone who helped with my last modification time issue.
In summary i did not have register_globals on and the code now is:

<?

echo "This file was last modified: ";

$temp = pathinfo($_SERVER['PHP_SELF']);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>



Hope this helps someone and again thanks for the assist.

Dave.




Chung Leong
 
Posts: n/a
#5: Jul 17 '05

re: php displaying last modification time


Use $_SERVER['SCRIPT_FILENAME'] instead. PHP_SELF is the URI of the running
script. Your script would fail if some of letters in URI are in the wrong
case.

Uzytkownik "dave" <dmehler26@woh.rr.com> napisal w wiadomosci
news:iPrLb.2838$RT.1226@fe2.columbus.rr.com...[color=blue]
> Hello,
> Trying to get a php script to display when a web page was last[/color]
modified.[color=blue]
> My code is below, i'm getting a last modified date of dec. 31 1969 which[/color]
is[color=blue]
> wrong for one, and does not change if i modify the resulting file. The[/color]
code[color=blue]
> itself is in an include file, a footer file, which will be included at the
> bottom of every page. Suggestions?
> Thanks.
> Dave.
>
> <?
>
> echo "This file was last modified: ";
>
> $temp = pathinfo($PHP_SELF);
>
> echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));
>
> ?>
>
>[/color]


Closed Thread