[PHP-DOC] #22342 [Bgs->Dup]: the behaviour of require(..) or die(..); is non-intuitive From: hholzgra <email protected>
Date: 02/21/03

 ID: 22342
 Updated by: hholzgra <email protected>
 Reported By: peter-phpbug at dataloss dot nl
-Status: Bogus
+Status: Duplicate
 Bug Type: Documentation problem
 Operating System: Linux
 PHP Version: 4.3.1
 New Comment:

dup. of #15438

operator precedence problem: or is evaluated before require

i have to confess that the sample doesn't make sense for require, but
it is at least a documentation problem for include:

  include("somefile") or die(...);

whereas

  (include("somefile")) or die(...);

works as expected

IMHO the WTF factor here is rather big ... :(

Previous Comments:
------------------------------------------------------------------------

[2003-02-21 04:51:13] sniper <email protected>

require() dies with fatal error if file is not found..

------------------------------------------------------------------------

[2003-02-20 18:14:23] peter-phpbug at dataloss dot nl

If one would use a line similar to

require("include/xhtml11.php") or die("argh!");

php will fail stating it cannot open "1".

The more intuitive result can be obtained by doing

(require("include/xhtml11.php")) or die("argh!");

I know that require or die is wrong, since require is not a function.
However, due to the way precedence (apparently) works with require, the
result is non-intuitive and confusing (I am assuming php is evaluating
'(..) or die(..)' to 'true', which is 1).

------------------------------------------------------------------------

-- 
Edit this bug report at http://bugs.php.net/?id=22342&edit=1

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