On 11 November 2005 20:52, Jay Blanchard wrote:

> $theFile = fopen("docs/InstallationInstructionMaster.txt", "r") ||
> die;

You need "or" not || here.  The operator priorities are such that the above 
means

  $theFile = (fopen("docs/InstallationInstructionMaster.txt", "r") || die);

which assigns TRUE to $the File when the fopen() succeeds, rather than the file 
handle.  You can't have error reporting turned up very high, or this:
 
> while(!feof($theFile)){
>       $theLine = fgets($theFile, 4096);
>       echo $theLine . "<br>\n";
> }

would be throwing all sorts of warnings about the invalid file handle.  I'm 
guessing that feof(TRUE) returns NULL as well as throwing the warning, so this 
should be an infinite loop echoing just linebreaks.  Oh, wait....! ;)

On the other hand, the version using "or" works out to be:

   ($theFile = fopen("docs/InstallationInstructionMaster.txt", "r")) or die;

which assigns the result of fopen() to $theFile, and then executes die if it's 
false -- which is much more satisfactory. ;)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to