我有以下警告应该在那里,但有没有办法阻止他们写入页面而不实际禁用全局警告?PHP停止警告1行代码
警告:
警告:的file_get_contents(E:/connected.txt):未能打开流: C中没有这样的文件或目录:\ XAMPP \ htdocs中\ PPA \上线的test.php 19
警告:的file_get_contents(F:/connected.txt):未能打开流: 在C无这样的文件或目录:\ XAMPP \ htdocs中\ PPA \ test.php的第19行
警告: file_get_contents(G:/connected.txt):无法打开流: 否第19行的C:\ xampp \ htdocs \ ppa \ test.php中的uch文件或目录
警告:file_get_contents(H:/connected.txt):未能打开流: C: \ XAMPP \ htdocs中\ PPA上线\ test.php的19
警告:的file_get_contents(I:/connected.txt):未能打开流: C中没有这样的文件或目录:\ XAMPP \ htdocs中\ PPA \上线19 test.php的
警告:的file_get_contents(Y:/connected.txt):未能打开流: 在C无这样的文件或目录:\ XAMPP \ htdocs中\ PPA \上线19
test.php的警告:的file_get_contents(K:/connected.txt):未能打开流: 在C无这样的文件或目录:\ XAMPP \ htdocs中\ PPA \ test.php的第19行
警告:的file_get_contents( L:/connected.txt):无法打开流: 第19行中的C:\ xampp \ htdocs \ ppa \ test.php中没有此文件或目录
警告:file_get_contents(M:/connected.txt) :未能打开流: 第19行中的C:\ xampp \ htdocs \ ppa \ test.php中没有此文件或目录
警告:file_get_contents(N:/connected.txt):未能打开流: 在C无这样的文件或目录:\ XAMPP \ htdocs中\ PPA \ test.php的第19行
警告:的file_get_contents(O:/connected.txt):未能打开流: 没有这样的文件或在目录C:\ XAMPP \ htdocs中\ PPA \ test.php的第19行
警告:的file_get_contents(P:/connected.txt):未能打开流: 在C无这样的文件或目录:\ XAMPP \ htdocs中\ PPA \上线test.php的19
PHP功能:
//Check if the connection file is present on each drive
function scanDrives() {
//Possible drives
$letters = "DEFGHIJKLMNOP";
$letters = str_split($letters);
$code = md5("FMbHSBTMTXhu3TWp");
//Check for a certain file on each device
foreach($letters as $x) {
$file = file_get_contents($x.":/connected.txt"); //This is what causes the error as the file can't be found.
if ($file != false) {
$file_code = split(":", $file);
//Check if the file has the correct pass code
if($file_code[0] == $code) {
//Successful, return pass value and device letter and set name
echo (1).",".$x.",".$file_code[1];
}
}
}
}
谢谢。
这比使用'@'抑制更好。 +1 – naththedeveloper
@FDL:我会*从不*建议'@'操作符。它总是*更好地检查/处理错误,而不是盲目地忽略它们:-) –