Possible Duplicate:
Why 'defined() || define()' syntax in defining a constant
This piece of code is created by the zf tool that Zend Framework provides.
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
My questions is :
What is the purpose of this line of code? There are no conditional statements such as if, switch. Does it imply a conditional statement automatically?
Here is how i understand it:
if APPLICATION_PATH is defined, leave it alone else set it to : realpath(dirname(__FILE__) . '/../application').
If my assumption is true this is a really confusing syntax.
Any help will be appreciated.
Your assumption is correct. This is just a short hand way of saying
You can easily test this:
Output is
bar.Output is
baz.