3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(defined("WHATEVER_THIS_ISNT_DEFINED")){ // double quotes needed! echo 'yup, constant defined'; } else { echo 'nope, does not exist'; } if(defined('WHATEVER_THIS_ISNT_DEFINED')){ // single quotes won't suppress error notice? no, they work! echo 'yup, constant defined'; } else { echo 'nope, does not exist'; } if(defined(WHATEVER_THIS_ISNT_DEFINED)){ // no quotes then error notice echo 'yup, constant defined'; } else { echo 'nope, does not exist'; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
nope, does not existnope, does not exist Fatal error: Uncaught Error: Undefined constant "WHATEVER_THIS_ISNT_DEFINED" in /in/9gGRD:17 Stack trace: #0 {main} thrown in /in/9gGRD on line 17
Process exited with code 255.
Output for 7.2.6 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
nope, does not existnope, does not exist Warning: Use of undefined constant WHATEVER_THIS_ISNT_DEFINED - assumed 'WHATEVER_THIS_ISNT_DEFINED' (this will throw an Error in a future version of PHP) in /in/9gGRD on line 17 nope, does not exist
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
nope, does not existnope, does not exist Notice: Use of undefined constant WHATEVER_THIS_ISNT_DEFINED - assumed 'WHATEVER_THIS_ISNT_DEFINED' in /in/9gGRD on line 17 nope, does not exist

preferences:
245.61 ms | 404 KiB | 359 Q