Created
July 22, 2013 05:41
-
-
Save WenLiangTseng/6051520 to your computer and use it in GitHub Desktop.
使用CURL抓資料的PHP函數,可以給予URL資料,然後得到回傳的結果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xml_file = file_get_contents(SITE_PATH . 'cms/data.php'); | |
//CURL | |
function url_get_contents ($Url) { | |
if (!function_exists('curl_init')){ | |
die('CURL is not installed!'); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $Url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment