Checking if open file succeded



examples/files/open_fails_checked.php
<?php
    if ($fd = fopen("no_such_dir/text.txt", "r")) {
       print "Sno_such_dir/text.txt succeeded<br>";
    }
    print "Still running<br>";

    if ($fd = fopen("data/text.txt", "r")) {
       print "data/text.txt succeeded<br>";
    }
?>

Warning: fopen(no_such_dir/text.txt): failed to open stream:
   No such file or directory in .../php/examples/files/open_fails.php on line 2
Still running
data/text.txt succeeded