Q:

php: constant variable attach with stdclass

Is it possible to call a data from database by attaching a constant variable like this?
$table_result->description_{constant_varible};

So that the actual stdclass I intend to call is $table_result->description_B; return '34';
Thanks

A:

Yes, it's possible.  E.g. via $obj->{expr} 
<?php
$v = 'B'; // or a constant, doesn't matter
$table_result = foo();
echo $table_result->{'description_'.$v};

function foo() {
    $x = new StdClass;
    $x->description_B = 34;
    return $x;
}

