note 21371 rejected from control-structures.elseif by zak
| From: | zak@php.net | Date: | Fri, 10 May 2002 05:27:03 +0000 |
| Subject: | note 21371 rejected from control-structures.elseif by zak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-30416@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