Alternative for file_get_contents()
There are some shared webhosts that have the populair PHP function file_get_contents() disabled. Since there are alot of scripts that need to fetch data from a website it’s crucial that it works.
Therefor I offer the webmasters this alternative:
<?php $file_contents = file_get_contents(’http://example.com/‘); // display file echo $file_contents; ?> BECOMES: <?php $site_url = ‘http://example.com‘; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $site_url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); ob_start(); curl_exec($ch); curl_close($ch); $file_contents = ob_get_contents(); ob_end_clean(); echo $file_contents; ?>
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
![[Google]]( http://www.warezteacher.com/wp-content/plugins/easy-adsenser/google-light.gif)

June 1st, 2009 at 9:58 AM
this should be turned into a function and should be coded better but the basic objective is there !