3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { // protected $compat_fields = array(); public function __construct() { } } class Foo extends Bar { public function __construct() { parent::__construct(); if ( $this->compat_fields && is_array( $this->compat_fields ) ) { array_push( $this->compat_fields, 'all_items' ); } $this->all_items = array(); } } $foo = new Foo(); var_dump( $foo->all_items );

preferences:
58.53 ms | 405 KiB | 5 Q