If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Of course external.php must consist exclusively of valid php code, that means no opening <?php and closing tags inside etc. Sadly, if your host has all include... functions disabled, I assume they have the filesystem functions disabled as well.

On some apache servers you can set those php configuration values directly in a .htaccess file. More info about that can be found at http://za2.php.net/manual/en/configuration.php. This option can also be disabled by the server admin and depends highly on each single configuration of the server your script is running on.

For me it seems your host has a quite restrictive safe_mode configuration working (see also http://za2.php.net/manual/en/features.safe-mode.php and what *could* be done to circumvent this). Frankly, I would write them a polite email and request that they reconsider their PHP security configuration. Because include and require are essential for PHP programming, unless you want to rewrite every script of yours.

If they still refuse to change their security policy, ditch them and change hosts.

Basically that's correct and your last alternative. Only make sure that you don't copy redundant code, say if one function is in include1.php and in include2.php, you only need it to copy once to your script.

About the host: That's why I pay for my hosting. Invaluable the occasional email communication with the server support.

mordred, you mentioned above that when using filesystem commands, the file to be used cannot contain PHP code itself. Is that true of include()? (i.e. can I include a file which has includes inside it?)

Originally posted by skinme!
mordred, you mentioned above that when using filesystem commands, the file to be used cannot contain PHP code itself.

No, I did not say that. What I describe was an example how to open a file and evaluate it's complete contents through the eval() function. Such a file most contain *only* php code, since eval("<php") gives you an error.

include et al are also not filesystem functions. They are language constructs, though they work in manner that relates to opening a file through the filesystem functions.

Hope that clears things up.

Ah, one thing more: You need to use <?php and ?> on included files because with the include constructs, PHP drops out of the php parsing. That's pretty handy because you can put large static HTML content into a template file and just include() it to write it to the output.