php如果出现错误 执行其它代码
ovovo 2008-11-26 01:43:35 $base_url = "http://www.1234.com/index.php";
$thisHttp = new cHTTP();
$thisHttp->setReferer($base_url);
$filename="http://www.1234.com/2index.php";
$thisHttp->getPage($filename);
$msg = $thisHttp->getContent();
$meg = gzinflate (substr ($msg, 10)); //如果远程地址无法打开,这一行就会报错 'Warning: gzinflate() [function.gzinflate]: data error in........'
preg_match_all("/Array\((.+?)\);/is",$meg,$matches);
$cou=sizeof($matches[0]);
-----------------------------------------------
请问如何当远程地址无法打开的时候,不让它报错,并执行echo "远程网页无法打开"
也就是说 如何当网页出现"Warning: gzinflate() [function.gzinflate]: data error in ....."不让它出现而执行 其它代码?
搜了一下 感觉try{}catch{} 能搞定,可否给个例子?谢谢各位了