note 78081 deleted from function.file by bjori
| From: | bjori@php.net | Date: | Thu, 27 Sep 2007 12:27:31 +0000 |
| Subject: | note 78081 deleted from function.file by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130840@lists.php.net to get a copy of this message | ||
Note Submitter: pehden at yahoo dot com
----
"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
}
?>