12

I am unable to include a remote PHP file in my PHP script. I suppose my hosting changed php settings.

The code I was using was:

include "http://domain.com/folder/file.php";

How do I allow enable the include function using php.ini/.htaccess ?

Is there any other workaround?

Thanks.

2
  • I just checked and both allow_url_fopen and allow_url_include are 'on' on my server. Could there be some other problem? Commented Jul 21, 2009 at 10:50
  • WHat's the URL you are trying to include?
    – Paul Dixon
    Commented Jul 21, 2009 at 13:37

2 Answers 2

24

To allow inclusion of remote files, the directive allow_url_include must be set to On in php.ini

But it is bad, in a security-oriented point of view ; and, so, it is generally disabled (I've never seen it enabled, actually)

It is not the same as allow_url_fopen, which deals with opening (and not including) remote files -- and this one is generally enabled, because it makes fetching of data through HTTP much easier (easier than using curl)

1
  • 1
    Depending on the serverconfiguration (version of PHP) . allow_url_include => Available since PHP 5.2.0. Deprecated as of PHP 7.4.0. Commented Apr 10, 2020 at 7:25
4

To use remote includes, the allow_url_fopen and allow_url_include option must be set in php.ini

Be aware that if the remote server is php-enabled, you'll get the output of that remote script, not the script itself. If you do want to fetch the source, you could add a symlink on the remote server, e.g. ln -s file.php file.php.source and then make your include reference file.php.source instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.