3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MaritalStatusProvider { const SINGLE = 'choices.maritalStatus.single'; const MARRIED = 'choices.maritalStatus.married'; const WIDOW = 'choices.maritalStatus.widow'; const DIVORCED = 'choices.maritalStatus.divorced'; private static $maritalStatusKeys = array( self::SINGLE, self::MARRIED, self::WIDOW, self::DIVORCED ); /** * Get Type Choices * * @return array */ public static function getTypeChoices() { return array_combine(self::$maritalStatusKeys, self::$maritalStatusKeys); } } $getMaritalStatus = 'choices.maritalStatus.married'; if ($getMaritalStatus == null || !in_array($getMaritalStatus, array(MaritalStatusProvider::SINGLE, MaritalStatusProvider::WIDOW)) ) { print_r(array('titular', 'next', 'save')); } else { print_r(array('titular', 'next', 'save', 'married')); }
based on L4Z0X
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => titular [1] => next [2] => save )
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XQ01X on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XQ01X on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/XQ01X on line 4
Process exited with code 255.