3v4l.org

run code in 300+ PHP versions simultaneously
<?php function unregister_setting( $option_group, $option_name, $deprecated = '' ) { global $new_allowed_options; // Before. $pos = array_search( $option_name, (array) $new_allowed_options[ $option_group ], true ); // After. return $pos; } // Scenario 1: Raises "Warning: Trying to access array offset on value of type null" echo "Scenario 1: \n"; $new_allowed_options = null; var_dump( unregister_setting( 'unknown_setting_group', 'unknown_setting_name' ) ); // Scenario 2: Raises "Warning: Undefined array key "unknown_setting_group" " echo "\nScenario 2: \n"; $new_allowed_options = array(); var_dump( unregister_setting( 'unknown_setting_group', 'unknown_setting_name' ) ); // Scenario 3: Does not riase a Notice|Warning. echo "\nScenario 3: \n"; $new_allowed_options = array( 'unknown_setting_group' => array() ); var_dump( unregister_setting( 'unknown_setting_group', 'unknown_setting_name' ) ); // Scenario 4: Does not riase a Notice|Warning. echo "\nScenario 4: \n"; $new_allowed_options = array( 'unknown_setting_group' => null ); var_dump( unregister_setting( 'unknown_setting_group', 'unknown_setting_name' ) );
Output for 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Scenario 1: Warning: Trying to access array offset on null in /in/oeFUJ on line 7 bool(false) Scenario 2: Warning: Undefined array key "unknown_setting_group" in /in/oeFUJ on line 7 bool(false) Scenario 3: bool(false) Scenario 4: bool(false)
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27
Scenario 1: Warning: Trying to access array offset on value of type null in /in/oeFUJ on line 7 bool(false) Scenario 2: Warning: Undefined array key "unknown_setting_group" in /in/oeFUJ on line 7 bool(false) Scenario 3: bool(false) Scenario 4: bool(false)
Output for 7.4.0 - 7.4.33
Scenario 1: Notice: Trying to access array offset on value of type null in /in/oeFUJ on line 7 bool(false) Scenario 2: Notice: Undefined index: unknown_setting_group in /in/oeFUJ on line 7 bool(false) Scenario 3: bool(false) Scenario 4: bool(false)
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33
Scenario 1: bool(false) Scenario 2: Notice: Undefined index: unknown_setting_group in /in/oeFUJ on line 7 bool(false) Scenario 3: bool(false) Scenario 4: bool(false)
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
Scenario 1: bool(false) Scenario 2: Notice: Undefined index: unknown_setting_group in /in/oeFUJ on line 7 bool(false) Scenario 3: bool(false) Scenario 4: bool(false)

preferences:
95.15 ms | 413 KiB | 5 Q