3v4l.org

run code in 300+ PHP versions simultaneously
<?php $users = [ 1 => 'Hello World' ]; $_SESSION['user_id'] = 'ABC'; if (\array_key_exists('user_id', $_SESSION) && $user_id = \filter_var($_SESSION['user_id'], \FILTER_VALIDATE_INT)) { //not executed $user = $users[$user_id]; var_dump($user); } $_SESSION['user_id'] = '1'; if (\array_key_exists('user_id', $_SESSION) && $user_id = \filter_var($_SESSION['user_id'], \FILTER_VALIDATE_INT)) { $user = $users[$user_id]; var_dump($user); } $_SESSION['user_id'] = 'ABC'; if (!empty($_SESSION['user_id'])) { $user_id = $_SESSION['user_id']; $user = $users[$user_id]; //error var_dump($user); //null }
Output for git.master, git.master_jit, rfc.property-hooks
string(11) "Hello World" Warning: Undefined array key "ABC" in /in/WBIPe on line 24 NULL

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.09 ms | 1391 KiB | 4 Q