I came across this interesting line in the default index.php file for a Zend Framework project:
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
It seems to be saying “If APPLICATION_PATH is not defined, then go on and define it…”
I’m not aware of this control structure in PHP. It’s almost like an ‘implied if’ or ‘if/else’. Can anyone help me out on this?
It is not a control structure – it is just how
||works. If first operand was evaluated totrue– then second is not being evaluated at all.http://php.net/manual/en/language.operators.logical.php — look at the first 4 lines of the sample.