3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a{ public $b=['f'=>'c']; } $a=new a; $b='b'; echo $a->b['f']; // without the $ it works $x = $a->$b; // otherwise you need to assign first echo $x['f']; // now it works echo $a->{$b}['f']; // or wrapped in curlies

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
209.11 ms | 2548 KiB | 10 Q