How to include remote data in a PHP script when allow_url_include is not active
Who develops in PHP may have already encountered this problem:
A PHP script that uses the include function to include data from a remote file via http.
Example:
include ("http://www.site.com.br/arquivo.htm)
For this function can be used that way, it is necessary that the configuration directives allow_url_fopen and allow_url_include (from version 5.2.0) are active.
However, some hosting services are adopting security policies that disable these policies.
If this is the case, one solution is to use functions of the CURL library . She is a library created by Daniel Stenberg that allows connection and communication with various servers using different protocols such as http, https, ftp, gopher, telnet, dict, file, and ldap.
This library must be compiled and installed PHP on your server. Learn more by clicking here .
Here is a very simple way to replace the function call to include PHP using CURL:
$ Ch = curl_init ();
curl_setopt ($ ch, CURLOPT_URL, "http://www.site.com.br/arquivo.htm");
curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1);
$ Output = curl_exec ($ ch);
if (! curl_errno ($ ch))
(
curl_close ($ ch);
echo $ output;
)
else
(
curl_error print ($ ch);
)
It's more code, but is more efficient and secure. Besides working with policies allow_url_fopen and allow_url_include disabled.
Compare DVD recorder in the Rocket.
Offers: Kingston 2GB Pen Drive , Seagate 320gb Hd .
This tutorial has been helpful to you?
Can you help me creating new tutorials and maintain this site!
Liked this article? Help spread ...
New here?!
Before leaving be sure to subscribe to RSS feed or receive items by email .





3 comments on "How to include remote data in a PHP script when allow_url_include is not active"
Then you can for a few frozen on my account ... thanks!
Hello Jaum,
You can leave!
But if you want, you can start making a donation.
It has a link on the bar to the right of the blog, just for that!
Hug.