note 78081 added to function.file

From: Date: Thu, 27 Sep 2007 05:43:04 +0000
Subject: note 78081 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-130822@lists.php.net to get a copy of this message
"heres a little script to return a random quote from a quotes file. <?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 } ?> " I tried this code but there was on thing wrong with it here is what i did and it works great I removed the Includes/ thing and now it works. <?php $textfile = "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 } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 74.221.40.191 ---- Manual Page -- http://www.php.net/manual/en/function.file.php Edit -- https://master.php.net/note/edit/78081 Del: integrated -- https://master.php.net/note/delete/78081/integrated Del: useless -- https://master.php.net/note/delete/78081/useless Del: bad code -- https://master.php.net/note/delete/78081/bad+code Del: spam -- https://master.php.net/note/delete/78081/spam Del: non-english -- https://master.php.net/note/delete/78081/non-english Del: in docs -- https://master.php.net/note/delete/78081/in+docs Del: other reasons-- https://master.php.net/note/delete/78081 Reject -- https://master.php.net/note/reject/78081 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130822) next »