note 30735 added to function.include
| From: | tjic at tjic dot com | Date: | Thu, 27 Mar 2003 02:46:54 +0000 |
| Subject: | note 30735 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45875@lists.php.net to get a copy of this message | ||
If you write a file 'a.php' such that it:
1) includes a file <B> by HTTP
2) specifies a webserver that has PHP processing
(perhaps the same server that is serving a.php)
3) the file <B> has a name that invokes server php processing
(such as 'b.php')
then you should be aware that the file b.php will be fully processed to
generate HTML by the webserver before it is delivered to file 'a.php'.
This means that if all three of the above things are true, you can not
include a file that supplies function definitions or variable manipulation.
E.g.:
at site foobar.net:
a.php:
<?
echo "X";
include("http://www.foobar.net/b.php");
echo "Y";
echo $z;
?>
b.php:
<?
echo "b";
$z="Z";
?>
will result in an HTML document when a.php is viewed:
XbY
and not
XbYZ
as might be desired.
The secret is to rename file b.php to something that will not cause the webserver to evaluate it as
PHP.
"b.phpINCLUDE" will most likely work.
If you are using apache, look in your httpd.conf file for a line
that starts "AddType application/x-httpd-php" and note
the file extensions specified there.
Now pick an extension that is not on that line.
TJIC
(http://www.tjic.com)
--
http://www.php.net/manual/en/function.include.php
http://master.php.net/manage/user-notes.php?action=edit+30735
http://master.php.net/manage/user-notes.php?action=delete+30735
http://master.php.net/manage/user-notes.php?action=reject+30735