3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php define('DEFINED_AS_TRUE', true); define('DEFINED_AS_FALSE', false); echo 'Case A when not defined: '; if ((!THIS_IS_NOT_DEFINED) || !defined('THIS_IS_NOT_DEFINED')) { echo 'if is true'; } else { echo 'if is false'; } echo "\n\n"; echo 'Case B when not defined: '; if ((!defined('THIS_IS_NOT_DEFINED')) || (!THIS_IS_NOT_DEFINED)) { echo 'if is true'; } else { echo 'if is false'; } echo "\n\n"; echo 'Case A when defined as true: '; if ((!DEFINED_AS_TRUE) || !defined('DEFINED_AS_TRUE')) { echo 'if is true'; } else { echo 'if is false'; } echo "\n\n"; echo 'Case B when defined as true: '; if ((!defined('DEFINED_AS_TRUE')) || (!DEFINED_AS_TRUE)) { echo 'if is true'; } else { echo 'if is false'; } echo "\n\n"; echo 'Case A when defined as false: '; if ((!DEFINED_AS_FALSE) || !defined('DEFINED_AS_FALSE')) { echo 'if is true'; } else { echo 'if is false'; } echo "\n\n"; echo 'Case B when defined as false: '; if ((!defined('DEFINED_AS_FALSE')) || (!DEFINED_AS_FALSE)) { echo 'if is true'; } else { echo 'if is false'; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Case A when not defined: Notice: Use of undefined constant THIS_IS_NOT_DEFINED - assumed 'THIS_IS_NOT_DEFINED' in /in/ED6iJ on line 6 if is true Case B when not defined: if is true Case A when defined as true: if is false Case B when defined as true: if is false Case A when defined as false: if is true Case B when defined as false: if is true