
我想在我的代码中使用那个错误,例如。
if(Not Found In Database) then
show alert"Data Not Found In Database"如何将错误包含到我的变量中?
*注:我使用的是Laravel-7
发布于 2021-10-25 06:49:38
你可以试试
throw new \Exception("error");使用curl编辑和添加检查exist文件的函数
function checkUrlExistFile($url): bool {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($info == '200') return true;
return false;
}和例子
if (!checkUrlExistFile($url)) {
throw new \Exception("error");
}发布于 2021-10-25 06:34:38
首先检查你是否有记录:
$data = model::all();
if($data == NULL) {
echo "<script>alert('data not found')</script>"
}https://stackoverflow.com/questions/69703031
复制相似问题