file_get_contents do not throw an exception in the error, instead it returns false, so you can check if the return value is false:
$json = file_get_contents("sidiowdiowjdiso", true); if ($json === false) {
Thus, you will still receive a warning, if you want to remove it, you need to put @ in front of file_get_contents . (This is considered bad practice)
$json = @file_get_contents("sidiowdiowjdiso", true);
source share