3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $row = new stdClass; $field_name = 'field_my_field'; $delta = 0; $row->{$field_name}[$delta] = 'value'; // This works just fine. echo 'field_name by itself: ' . $row->$field_name[0]; $row->{$field_name . ':title'}[$delta] = 'value'; // This doesn't work. echo '/n1: ' . $row->$field_name[0]; $title_field = $field_name . ':title'; $row->{$title_field}[$delta] = 'value'; // This doesn't work. echo '/n2: ' . $row->$field_name[0];
based on i2aeL
Output for 7.0.0 - 7.2.0
field_name by itself: value/n1: value/n2: value
Output for 5.3.19 - 5.6.28
Notice: Undefined property: stdClass::$f in /in/DEl3Z on line 7 field_name by itself: Notice: Undefined property: stdClass::$f in /in/DEl3Z on line 10 /n1: Notice: Undefined property: stdClass::$f in /in/DEl3Z on line 14 /n2: