Problem with Include
| From: | Bill Guion | Date: | Sun, 19 Dec 2010 16:43:54 +0000 |
| Subject: | Problem with Include | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-310140@lists.php.net to get a copy of this message | ||
In an effort to clean up some code, I tried taking four lines out of 6 or 7 programs and putting them into an include file. The file structure is
Root
data
clubs.phpinclude
fmt.incOriginally, clubs.php had the following code: <?PHP $file_name= basename($_SERVER['PHP_SELF']); $last_modified = filemtime($file_name); print("This page last modified "); print(date("m/j/y", $last_modified)); ?> This code works - on the web page I get This page last modified 12/18/2010 which is correct. So then I did the following: Create an include file, fmt.inc with the following code: $file_name= basename($_SERVER['PHP_SELF']); $last_modified = filemtime($file_name); print("This page last modified "); print(date("m/j/y", $last_modified)); and then in the original file, I have <?PHP include "../include/fmt.inc"; ?> On my web page, I then get $file_name= basename($_SERVER['PHP_SELF']);$last_modified = filemtime($file_name);print("This page last modified "); print(date("m/j/y", $last_modified)); (all on one line). I would really like to understand why the include construct doesn't give the same results as the original?
-----===== Bill =====-----