Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13432
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: 404 error |
| Date | 2014-04-22 23:26 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1747044.jrh1OFUs5G@PointedEars.de> (permalink) |
| References | <7f2rl4.2fb.17.1@news.alt.net> |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-22 12:41 -0400
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-22 12:58 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-22 13:25 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-22 13:32 -0400
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-22 14:35 -0400
Re: 404 error Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-04-22 14:42 -0400
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-22 14:56 -0400
Re: 404 error Anders Wegge Keller <wegge@wegge.dk> - 2014-04-23 08:56 +0200
Re: 404 error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-23 13:12 +0200
Re: 404 error Anders Wegge Keller <wegge@wegge.dk> - 2014-04-23 13:23 +0200
Re: 404 error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-23 13:36 +0200
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-23 08:09 -0400
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-23 08:08 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-23 13:12 -0400
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-23 14:50 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-23 20:19 -0400
Re: 404 error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-22 23:26 +0200
Re: 404 error Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-23 14:21 +0200
Re: 404 error Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-23 09:12 -0400
SCRIPT_NAME (was: 404 error) Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-23 21:46 +0200
Re: SCRIPT_NAME Jerry Stuckle <jstucklex@attglobal.net> - 2014-04-23 16:36 -0400
Re: SCRIPT_NAME Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-24 00:27 +0200
Re: SCRIPT_NAME Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-25 00:35 +0200
Re: 404 error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-23 15:56 +0200
Re: 404 error Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-23 18:00 +0200
Re: 404 error Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-23 21:38 +0200
Re: 404 error Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-04-22 22:04 +0000
Re: 404 error The Natural Philosopher <tnp@invalid.invalid> - 2014-04-23 00:11 +0100
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-22 20:22 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-23 12:39 -0400
Re: 404 error Ed Mullen <ejEVOMER@edmullen.net> - 2014-04-23 14:22 -0400
Re: 404 error Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-23 21:28 +0000
csiph-web