note 17868 added to function.fopen

From: Date: Sat, 29 Dec 2001 23:54:11 +0000
Subject: note 17868 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-23949@lists.php.net to get a copy of this message
Attn Perl Programmers: If you are used to writing script like do something || die("no can do"); note that in php || has a higher precedence than = So, don't write: $h = fopen("$filename", "r") || die("cannot open $filename"); b/c this will overwrite the file ptr! Now, or has a lower precedence than || and is also lower than = So, you may write: $h = fopen("$filename","r") or die("cannot open $filename"); However, you may avoid the entire issue with code like this: $h = fopen("$filename","r"); if (!$h) { die("unable to open $filename"); } -- http://www.php.net/manual/en/function.fopen.php http://master.php.net/manage/user-notes.php?action=edit+17868 http://master.php.net/manage/user-notes.php?action=delete+17868 http://master.php.net/manage/user-notes.php?action=reject+17868

« previous php.notes (#23949) next »