With and Without @fopen

fopen() opens a given file if it exist and shows warning error message if do not exist. Appending '@' to it hides the error message.
 
//Without @fopen
<?php
$file = fopen("test.txt", "r");
if($file){
while(! feof($file)) {
  $line = fgets($file);
  echo $line. "<br>";
}

fclose($file);
}
?>

Output:

Now when we append the fopen() with ‘@’ then this error message will get removed.

Leave a Reply

Your email address will not be published. Required fields are marked *