how exceptions(try, catch) work in php?
<p>I don't exactly know how exceptions work. as I assume, they should avoid php errors and display "my error message". for example, i want to open file</p>

<pre><code>class File{

   public $file;

   public function __construct($file)
   {
       try{
           $this-&gt;file = fopen($file,'r');
       }
       catch(Exception $e){
           echo "some error" . $e-&gt;getMessage();
       }
     }
  }

  $file = new File('/var/www/html/OOP/texts.txt');
</code></pre>

<p>it works. now I intentionally change the file name <code>texts.txt</code> to <code>tex.txt</code> just to see an error message from my catch block, but instead, php gives an error <code>Warning: fopen(/var/www/html/OOP/texts.txt): failed to open stream: No such file or directory in /var/www/html/OOP/file.php on line 169</code> . so it's php error, it doesn't display error message from catch block. What am I doing wrong? how exactly try/catch  works?</p>