note 85778 deleted from function.include by danbrown

From: Date: Mon, 18 May 2009 00:53:27 +0000
Subject: note 85778 deleted from function.include by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155443@lists.php.net to get a copy of this message
Note Submitter: jimmy dot axenhus at gmail dot com ---- Never use include in an if statement. <?php if(include('./foo.php') && $bar = "bar") { echo "FooBar"; } ?> This will not include the file foo.php, instad it will for some reason onclude the file "1" and print: Warning: include(1) [function.include]: failed to open stream: No such file or directory in (file) on line (line) Warning: include() [function.include]: Failed opening '1' for inclusion (include_path='.;C:\php5\pear') in (file) on line (line) This will also fail if you write: <?php if(include './foo.php' && $bar = "bar") { echo "FooBar"; } ?> This will not, however, fail if you write: <?php if(include('./foo.php')) { echo "FooBar"; } ?> PHP version: 5.2.5

« previous php.notes (#155443) next »