PHP错误处理代码
发表于:2024-03-02 20:28:30浏览:95次
PHP错误处理:
<?php
try {
$file = fopen('non_existent_file.txt', 'r');
if ($file) {
echo "File opened successfully.";
} else {
throw new Exception("Failed to open file.");
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
栏目分类全部>