ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Working with Files in PHP, Part 3
Subject:   line !== 'false'
Date:   2003-03-12 16:39:03
From:   johncogg
Response to: line !== 'false'

Although this behavior may work (not using the 'identical' comparison and just using a standard comparison) it is not to be relied on. For instance:


$myfile = "0"; // a filename whose name is '0'
if($myfile == false) {
echo "$myfile is false\n";
} else {
echo "$myfile is true.\n";
}


In this case, the string '0' will be evaluated as an integer value '0' which is in turn a boolean false. In order for this to behave properly you'd need to use the identical comparison === operator.


John


1 to 1 of 1
  1. line !== 'false'
    2005-03-17 10:11:01  Cerro [View]

1 to 1 of 1