3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[AllowDynamicProperties] class WP_Term { public $term_id; /** * Converts an object to array. * * @since 4.4.0 * * @return array Object as array. */ public function to_array() { return get_object_vars( $this ); } } $term = new WP_Term(); $term->term_id = 5; $term->foo = 'foo'; $term->bar = 'bar'; echo "Direct type cast to `(array)`\n"; var_dump( (array) $term ); echo "\n\nUsing to_array()\n"; var_dump( $term->to_array() );
Output for git.master, git.master_jit, rfc.property-hooks
Direct type cast to `(array)` array(3) { ["term_id"]=> int(5) ["foo"]=> string(3) "foo" ["bar"]=> string(3) "bar" } Using to_array() array(3) { ["term_id"]=> int(5) ["foo"]=> string(3) "foo" ["bar"]=> string(3) "bar" }

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:
85.61 ms | 406 KiB | 5 Q