
The code is as follows:
//$data1 = file_get_contents(‘http://bbs.chengdu.cn/i_index_newdata.php?fids=202,238,239,240,241,242,259,271’);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘http://bbs.chengdu.cn/i_index_newdata.php?fids=202,238,239,240,241,242,259,271’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);
$data1 = curl_exec($ch);
curl_close($ch);
Since I was reading the contents of a remote file, I ultimately decided to use curl to replace file_get_contents. I feel that both speed and stability have improved. During the process, I encountered an issue where clicking the update button failed to update the data. I finally resolved this problem by adding: curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);!
