php错误处理

it2024-01-15  69

如果没有错误处理机制会怎样?

文件没有打开,但仍然向下执行,输出了ok

<?php $file = fopen('./aaa.php','r'); echo 'ok'; /* 输出结果; Warning: fopen(./aaa.txt): failed to open stream: No such file or directory in F:\wamp\www\test.php on line 2 ok */

添加错误处理机制

使用file_exists()函数检查文件

最新回复(0)