PHP "require" oddity

Charles Curley charlescurley at
Thu Mar 21 13:18:56 MDT 2013

I hit an interesting glitch in PHP. I have Debian Stable, so php is
rather ancient, php5, version 5.3.3-7+squeeze15.

To include or require a file, the included file must start and end with
PHP tags, e.g. <? ?>. So says the documentation:

    When a file is included, parsing drops out of PHP mode and into
    HTML mode at the beginning of the target file, and resumes again at
    the end. For this reason, any code inside the target file which
    should be executed as PHP code must be enclosed within valid PHP
    start and end tags.

That is correct when the included file is either local to the virtual
tree, or in the include path, and the virtual tree is in the main file
space, e.g. /var/www, as in Debian.

It is not true when the virtual tree is in a user directory (e.g.
"", and the included file is in the user's tree.
There, the opening and closing tags not only are unnecessary, they
break the code.

You have to enable user space PHP in
apache's /etc/apache2/mods-available/php5.conf. I have not investigated
to see if the problem is there.


Charles Curley                  /"\    ASCII Ribbon Campaign
Looking for fine software       \ /    Respect for open standards
and/or writing?                  X     No HTML/RTF in email    / \    No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB

More information about the PLUG mailing list