相关疑难解决方法(0)

如何在PHP中处理file_get_contents()函数的警告?

我写了这样的PHP代码

$site="http://www.google.com";
$content = file_get_content($site);
echo $content;
Run Code Online (Sandbox Code Playgroud)

但当我删除"http://"时,$site我收到以下警告:

警告:file_get_contents(www.google.com)[function.file-get-contents]:无法打开流:

我尝试过try,catch但它没有用.

php warnings exception-handling function

290
推荐指数
9
解决办法
30万
查看次数

关闭php/mysql上的警告和错误

我得到了预期的通知和警告,并希望在我的php文件上关闭它们.错误是:

Warning: fsockopen()
Run Code Online (Sandbox Code Playgroud)

和通知是:

Notice: A non well formed numeric value encountered in
Run Code Online (Sandbox Code Playgroud)

我打算在这个PHP脚本中使用cron,并且不希望在任何地方记录任何错误或通知.

php mysql

51
推荐指数
4
解决办法
26万
查看次数

标签 统计

php ×2

exception-handling ×1

function ×1

mysql ×1

warnings ×1