3v4l.org

run code in 300+ PHP versions simultaneously
<?php class With_Magic_Methods { private $_args; protected $compat_fields = array( '_args' ); public function __get( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name; } } public function __set( $name, $value ) { if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name = $value; } } public function __isset( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { return isset( $this->$name ); } return false; } public function __unset( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { unset( $this->$name ); } } } class No_Magic_Methods { public $_args; } class WP_31_Version { /** * Various information about the current table * * @since 3.1.0 * @var array * @access private */ var $_args; /** * Constructor. The child class should call this constructor from it's own constructor * * @param array $args An associative array with information about the current table * @access protected */ function WP_List_Table( $args = array() ) {} } $wp_31_version = new WP_31_Version(); $current = new With_Magic_Methods(); $option2 = new No_Magic_Methods(); function _get() { global $wp_31_version, $current, $option2; echo "- - - - - - - - - - -\n"; echo "πŸ‘‰ Defined property: \n"; echo "- - - - - - - - - - -\n"; echo "πŸ”Έ WP 3.1 code: "; var_dump( $wp_31_version->_args ); echo "\nπŸ”Έ Current code: "; var_dump( $current->_args ); echo "\nπŸ”Έ Option 2: "; var_dump( $option2->_args ); echo "\n- - - - - - - - - - -\n"; echo "πŸ‘‰ Dynamic property: \n"; echo "- - - - - - - - - - -\n"; echo "πŸ”Έ WP 3.1 code: "; var_dump( $wp_31_version->_dynamic_property ); echo "\nπŸ”Έ Current code: "; var_dump( $current->_dynamic_property ); echo "\nπŸ”Έ Option 2: "; var_dump( $option2->_dynamic_property ); } function test_get( $message = '' ) { echo "*********************\n"; printf( "πŸ”ΆπŸ”Ά Test get%s πŸ”ΆπŸ”Ά\n", $message ); echo "*********************\n\n"; _get(); echo "\n\n"; } function test_isset( $message = '' ) { global $wp_31_version, $current, $option2; echo "*********************\n"; printf( "πŸ”ΆπŸ”Ά Test isset()%s πŸ”ΆπŸ”Ά\n", $message ); echo "*********************\n\n"; echo "- - - - - - - - - - -\n"; echo "πŸ‘‰ Defined property: \n"; echo "- - - - - - - - - - -\n"; echo "πŸ”Έ WP 3.1 code: "; var_dump( isset( $wp_31_version->_args ) ); echo "\nπŸ”Έ Current code: "; var_dump( isset( $current->_args ) ); echo "\nπŸ”Έ Option 2: "; var_dump( isset( $option2->_args ) ); echo "\n- - - - - - - - - - -\n"; echo "πŸ‘‰ Dynamic property: \n"; echo "- - - - - - - - - - -\n"; echo "πŸ”Έ WP 3.1 code: "; var_dump( isset( $wp_31_version->_dynamic_property ) ); echo "\nπŸ”Έ Current code: "; var_dump( isset( $current->_dynamic_property ) ); echo "\nπŸ”Έ Option 2: "; var_dump( isset( $option2->_dynamic_property ) ); echo "\n\n"; } function test_set( $message = '' ) { global $wp_31_version, $current, $option2; $new_value = array( 'test' ); $wp_31_version->_args = $new_value; $wp_31_version->_dynamic_property = $new_value; $current->_args = $new_value; $current->_dynamic_property = $new_value; $option2->_args = $new_value; $option2->_dynamic_property = $new_value; echo "*********************\n"; printf( "πŸ”ΆπŸ”Ά Test set%s πŸ”ΆπŸ”Ά\n\n", $message ); echo "*********************\n"; _get(); echo "\n\n"; } echo "\n ***** COMPARE WITH WP 3.1 WP_List_Table ***** \n\n"; test_get(); test_isset(); test_set(); // Unset. unset( $wp_31_version->_args ); unset( $wp_31_version->_dynamic_property ); unset( $current->_args ); unset( $current->_dynamic_property ); unset( $option2->_args ); unset( $option2->_dynamic_property ); test_get( ' after unset()' ); test_isset( ' after unset()' ); test_set( ' after unset()' ); test_isset( ' after unset() and set' ); run_test();
Output for 8.2.10 - 8.2.23, 8.3.0 - 8.3.11
***** COMPARE WITH WP 3.1 WP_List_Table ***** ********************* πŸ”ΆπŸ”Ά Test get πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: NULL - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79 NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83 NULL ********************* πŸ”ΆπŸ”Ά Test isset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) Deprecated: Creation of dynamic property WP_31_Version::$_dynamic_property is deprecated in /in/DZnjf on line 129 Deprecated: Creation of dynamic property No_Magic_Methods::$_dynamic_property is deprecated in /in/DZnjf on line 133 ********************* πŸ”ΆπŸ”Ά Test set πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: array(1) { [0]=> string(4) "test" } πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: NULL πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } ********************* πŸ”ΆπŸ”Ά Test get after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_args in /in/DZnjf on line 69 NULL πŸ”Έ Current code: Warning: Undefined property: With_Magic_Methods::$_args in /in/DZnjf on line 9 NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_args in /in/DZnjf on line 73 NULL - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79 NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83 NULL ********************* πŸ”ΆπŸ”Ά Test isset() after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) Deprecated: Creation of dynamic property WP_31_Version::$_dynamic_property is deprecated in /in/DZnjf on line 129 Deprecated: Creation of dynamic property No_Magic_Methods::$_dynamic_property is deprecated in /in/DZnjf on line 133 ********************* πŸ”ΆπŸ”Ά Test set after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: array(1) { [0]=> string(4) "test" } πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: NULL πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } ********************* πŸ”ΆπŸ”Ά Test isset() after unset() and set πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(true) πŸ”Έ Current code: bool(true) πŸ”Έ Option 2: bool(true) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(true) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(true) Fatal error: Uncaught Error: Call to undefined function run_test() in /in/DZnjf:162 Stack trace: #0 {main} thrown in /in/DZnjf on line 162
Process exited with code 255.
Output for 8.1.20 - 8.1.29
***** COMPARE WITH WP 3.1 WP_List_Table ***** ********************* πŸ”ΆπŸ”Ά Test get πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: NULL - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79 NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83 NULL ********************* πŸ”ΆπŸ”Ά Test isset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) ********************* πŸ”ΆπŸ”Ά Test set πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: array(1) { [0]=> string(4) "test" } πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: NULL πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } ********************* πŸ”ΆπŸ”Ά Test get after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_args in /in/DZnjf on line 69 NULL πŸ”Έ Current code: Warning: Undefined property: With_Magic_Methods::$_args in /in/DZnjf on line 9 NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_args in /in/DZnjf on line 73 NULL - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: Warning: Undefined property: WP_31_Version::$_dynamic_property in /in/DZnjf on line 79 NULL πŸ”Έ Current code: NULL πŸ”Έ Option 2: Warning: Undefined property: No_Magic_Methods::$_dynamic_property in /in/DZnjf on line 83 NULL ********************* πŸ”ΆπŸ”Ά Test isset() after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(false) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(false) ********************* πŸ”ΆπŸ”Ά Test set after unset() πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: array(1) { [0]=> string(4) "test" } πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: array(1) { [0]=> string(4) "test" } πŸ”Έ Current code: NULL πŸ”Έ Option 2: array(1) { [0]=> string(4) "test" } ********************* πŸ”ΆπŸ”Ά Test isset() after unset() and set πŸ”ΆπŸ”Ά ********************* - - - - - - - - - - - πŸ‘‰ Defined property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(true) πŸ”Έ Current code: bool(true) πŸ”Έ Option 2: bool(true) - - - - - - - - - - - πŸ‘‰ Dynamic property: - - - - - - - - - - - πŸ”Έ WP 3.1 code: bool(true) πŸ”Έ Current code: bool(false) πŸ”Έ Option 2: bool(true) Fatal error: Uncaught Error: Call to undefined function run_test() in /in/DZnjf:162 Stack trace: #0 {main} thrown in /in/DZnjf on line 162
Process exited with code 255.

preferences:
40.5 ms | 422 KiB | 5 Q