note 21371 added to control-structures.elseif

From: Date: Fri, 10 May 2002 04:39:35 +0000
Subject: note 21371 added to control-structures.elseif
Groups: php.notes 
Request: Send a blank email to php-notes+get-30414@lists.php.net to get a copy of this message
Sometimes you want to see if some files exsists so say: <?php error_reporting (E_ALL); $counter_file = "$DOCUMENT_ROOT/somefile.txt"; if(!($fp = @fopen($counter_file, "r"))) die ("<span class=\"error\"><b>Warning</b>: <b>$counter_file</b> in wrong directory or non-existent file. <a href=\"$DOCUMENT_ROOT\php-bin/\">Configure Server</a></span>"); $counter = (int) @fread($fp, 5); fclose($fp); // change from null to 1 $counter+="NULL"; $fp = fopen($counter_file, "w+"); fwrite($fp, $counter); fclose($counter_file); ?> with the if (!$fp) { the ! will see if it the file does exsist not $counter_file. Pretty good eh? http://members.lycos.co.uk/squaregamers -- http://www.php.net/manual/en/control-structures.elseif.php http://master.php.net/manage/user-notes.php?action=edit+21371 http://master.php.net/manage/user-notes.php?action=delete+21371 http://master.php.net/manage/user-notes.php?action=reject+21371

« previous php.notes (#30414) next »