Re: logical AND assignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The reason for "and" to have such a low precedence is so you can use it to
perform conditional processing. You can probably achieve every effect using
"&&", but you'd need more parentheses. More typically you would use "or" in
this fashion:

    defined('DS') or define('DS', DIRECTORY_SEPARATOR);

This checks if DS is defined and defines it if not.

    APP_ENV != 'prod' or die('This feature must not be used in production');

If we're in production, stop execution with an error. Using || here would
try to logically or the string 'prod' with the return value of die(). Of
course, die() doesn't return, so the script would exit no matter what
APP_ENV was set to.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux