Please answer this simple SPAM challenge: two plus four?
(Example: nine)

The Note You're Voting On

10 years ago
As mentioned below, PHP stops evaluating expressions as soon as the result is clear. So a nice shortcut for if-statements is logical AND -- if the left expression is false, then the right expression can’t possibly change the result anymore, so it’s not executed.

/* defines MYAPP_DIR if not already defined */
if (!defined('MYAPP_DIR')) {
define('MYAPP_DIR', dirname(getcwd()));

/* the same */
!defined('MYAPP_DIR') && define('MYAPP_DIR', dirname(getcwd()));

<< Back to user notes page

To Top