You need to use the curly braces if you want to access that way..
$myobject = new stdClass;
$prop = '12345';
$myobject->$prop = $prop;
echo $myobject->{12345}; //"prints" 12345
or simply echo $myobject->$prop
will do.
If you access it as echo $myobject->12345;
, below error will be thrown.
PHP Parse error: syntax error, unexpected '12345' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'