3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function charclass($flag) { define('WARRIOR_OFFSET', 16); define('MAGE_OFFSET', 17); define('CLASS_MASK', ( 1 << WARRIOR_OFFSET ) | ( 1 << MAGE_OFFSET )); define('CF_GOD', 1 << 2); // may issue #god commands define('CF_PLAYER', 1 << 3); // is a player define('CF_STAFF', 1 << 4); // member of the staff define('CF_INVISIBLE', 1 << 5); // character is completely invisible define('CF_GENDER', 1 << 14 | 1 << 15); // Determine Gender define('CF_ARCH', 1 << 18); // is arch-XXX define('CF_LQMASTER', 1 << 52); // may host LQs $classMap = array( 0b00 => 'error', 0b01 => 'warrior', 0b10 => 'mage', 0b11 => 'seyan', ); $class = $flag & CLASS_MASK; $class = $class >> WARRIOR_OFFSET; $class_name = $classMap[$class]; $is_god = $flag & CF_GOD; $is_arch = $flag & CF_ARCH; $is_staff = $flag & CF_STAFF; if ($is_god) { print "Godly "; } if ($is_staff) { print "Staffer "; } if ($is_arch) { print "Arch "; } print "$class_name\n"; } function chargender($flag) { define('MALE_OFFSET', 14); define('FEMALE_OFFSET', 15); define('GENDER_MASK', ( 1 << MALE_OFFSET ) | ( 1 << FEMALE_OFFSET )); $classMap = array( 0b00 => 'error', 0b01 => 'Male', 0b10 => 'Female', 0b11 => 'error', ); $gender = $bitmask & GENDER_MASK; $gender = $gender >> MALE_OFFSET; $gender_name = $classMap[$gender]; print "$gender_name\n"; } echo chargender(475149); echo charclass(475149);
Output for 5.4.0 - 7.1.0
Notice: Undefined variable: bitmask in /in/TMVP5 on line 58 error Godly Arch seyan
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/TMVP5 on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/TMVP5 on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/TMVP5 on line 15
Process exited with code 255.