note 46225 added to function.file

From: Date: Sun, 03 Oct 2004 07:33:03 +0000
Subject: note 46225 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-77776@lists.php.net to get a copy of this message
<?php $textfile = "Includes/Quotes.txt"; //quotes file if ($quotes = @file("$textfile")) { //don't display errors on file open $quote = rand(0, sizeof($quotes)-1); echo $quotes[$quote]; //echo a random quote }else{ echo ("default quote"); //if quotes file wasn't found, echo out a default quote } ?> Why all those variables? :x <?php $sTextfile = "Includes/Quotes.txt"; //quotes file if ($aQuotes = @file($sTextfile)) { // NO VARIABLES INSIDE QUOTES //don't display errors on file open echo $aQuotes[array_rand($aQuotes)]; //echo a random quote } else { echo 'blaat'; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46225 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46225&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46225&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77776) next »