Tuesday, November 18, 2008

cURL Alternative to PHP Include

cURL is usually installed with PHP on a server.  I ran into a problem where I needed to be able to include external URLs into a website.  The server I was using didn't allow for urls in the include field (allow_url_include was off).  So, I used this bit of code to do the same thing:

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'enter_external_url_here');
curl_exec($curl_handle);
curl_close($curl_handle);

Make sure to replace enter_external_url_here with the actual URL.  Quotes are required around the URL.

No comments: