即使使用我在网上找到的所有技巧,警告也不会被抑制

I want to suppress warnings, I searched on SO, found some solutions but they aren't working. I am getting Warning at following function(file_get_contents) when the internet connection is off. I know this functions requires internet connection, when the machine is not connected this function will show warning.

$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vid_id.php"));

first I tried using "@"

then I used error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

then I used error_reporting(0);

can anybody tell me how can I suppress these warnings?

If it's just for a single file, you can suppress the warning using @ like so:

$var = @file_get_contents("http://vimeo.com/api/v2/video/$vid_id.php");
$hash = unserialize($var);

But if you don't want to display any errors, you can edit your php.ini file and change the value of error_reporting to 0.

Make sure you restart Apache / webserver after making the changes to php.ini file.

Hope this helps!