Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gets file contents by URL (uses 'file_get_contents()' if 'allow_url_fopen' enabled, cUrl is not)
- * you should have cUrl installed or 'allow_url_fopen' enabled
- * @param $url file url string
- * @return String file contents
- */
- public static function getUrlContents($url)
- {
- # use cURL if 'allow_url_fopen' is disabled
- if(ini_get('allow_url_fopen'))
- {
- $result = file_get_contents($url);
- }else{
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
- $result = curl_exec($ch);
- curl_close($ch);
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement