FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » 404 error
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: 404 error [message #185626 is a reply to message #185613] Tue, 22 April 2014 21:26 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Ed Mullen wrote:

> <http://edmullen.net/index.php>
> <http://edmullen.net/bogus.php>
>
> Fine so far. The other site has different results.
> […]
> http://guitarsnotguns.org/rot.php
>
> Notice the error message and incorrect date in the footer.

It is not an error message, it is a *warning*.

> I'm guessing it's a server configuration issue. Any thoughts?
>
> BTW, here's the PHP I use on both sites:
>
> <?php
> $current_file_name = ($_SERVER['REQUEST_URI']);
> $current_path = ($_SERVER['DOCUMENT_ROOT']);

It is pointless and confusing for people accustomed to writing PHP code to
put the RHS into parentheses here.

> $full_name = $current_path.$current_file_name;
> $last_modified = filemtime($full_name);

Look closely at that warning. This approach is not going to work reliably
because the HTTP request URI does not need to have anything to do with the
file path of the resource. In fact, there does not even need to be a real
file for a URI, the served content could have been generated entirely by PHP
(and usually is). As a result, in those cases filemtime() returns FALSE …

> print(date("F j, Y - h:i A", $last_modified));

… which date() converts to 0 (UNIX epoch) – as it expects an int (UNIX
timestamp), not a boolean value, for the second argument – and formats that
accordingly to “December 31, 1969” (not “January 1, 1970 - 12:00 AM”
probably because of timezone issues), which is then send to stdout by
print(). (You should use “echo” instead, unless in an expression where you
need “print”’s return value. Think sh, not perl.)

,----
| $ php -r 'echo date("F, j Y - h:i A", filemtime("Slartibartfast")) .
| "\n";'
| PHP Warning: filemtime(): stat failed for Slartibartfast in Command line
| code on line 1
| PHP Stack trace:
| PHP 1. {main}() Command line code:0
| PHP 2. filemtime() Command line code:1
| January, 1 1970 - 01:00 AM
|
| $ php -v
| PHP 5.5.11-3 (cli) (built: Apr 19 2014 16:46:26)
| Copyright (c) 1997-2014 The PHP Group
| Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
| with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
| with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend
| Technologies
| with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans
| with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo
| with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo
| with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo
`----

(I am in UTC+2 now because of European Summer Time, and date.timezone is set
to “Europe/Zurich”; the latter would account for the one-hour advance.)

You might be looking for filemtime(__FILE__) instead.

<http://php.net/phpinfo>
<http://php.net/filemtime>
<http://php.net/date>
<http://php.net/print>
<http://php.net/echo>
<http://php.net/manual/en/language.constants.predefined.php>


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Use PHP to populate a Mailing list from a webpage
Next Topic: Re: Disaster Mitigation Program - Apr. 27, 2014
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue May 14 18:23:44 GMT 2024

Total time taken to generate the page: 0.05127 seconds