我使用phpQuery根据用户输入从页面中抓取一些信息,但是如果用户输入了不存在的内容,我会尝试设置错误处理。
例如,用户输入错误的产品编号可能会导致
Warning: file_get_contents([function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in 在这样的实例中,我可以在if语句中使用什么来检查phpQuery错误?
例如
if(...error...){
echo json_encode("error" => 'Incorrect value entered');
}发布于 2013-04-10 11:14:14
尝试将您计划用于try-catch块中的输入的逻辑包围起来。
类似于:
try {
<..insert your logic here..>
} catch (Exception $e) {
echo json_encode("error" => "Incorrect value entered");
}https://stackoverflow.com/questions/15916160
复制相似问题