php - fopen 前面有/没有@

标签 php file file-io

我见过在 fopen 之前使用 @ 的代码示例,如

$fh = @fopen($myFile, 'w');

这个@有什么意义?

最佳答案

它抑制表达式可能显示的错误。

您可以阅读更多相关信息 here .

例子:

file_get_contents('file_does_not_exist'); //this shows an error

@file_get_contents('file_does_not_exist'); //this does not

关于php - fopen 前面有/没有@,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2531720/

相关文章:

php - 将 HTML 选择选项值插入 mysql 表不起作用

php - JQuery.ajax 和对象和 php 的空响应

java从网络设备读取文件

c++ - Qt:将结构写入文件

c# - 带进度条的文件复制

PHP file_put_contents() 错误

php - 获取整个语言文件数组

HTML5 : What is the max number of files that can be selected on <input type ="file"/>

python - 提取进出 ipython/jupyter 笔记本的 pickle 的方法

multithreading - Golang中“打开的文件太多”而未打开任何文件