Re: Problem with Include
| From: | Tamara Temple | Date: | Sun, 19 Dec 2010 17:07:21 +0000 |
| Subject: | Re: Problem with Include | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310145@lists.php.net to get a copy of this message | ||
On Dec 19, 2010, at 10:43 AM, Bill Guion wrote:
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.php include fmt.inc Originally, 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?Whenever you see PHP code emitted to the web page, it means it wasn't wrapped in <?php..?>. If your include file above is complete, it's missing these tags.-----===== Bill =====-------PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php