Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you print an object, called * (asterisk)?

If print_r($object) returns

stdClass Object
(
    [*] => sometext
)

How do I get the property of the asterisk, i.e $object->*?

like image 460
timofey.com Avatar asked Sep 12 '12 06:09

timofey.com


4 Answers

You can access the property like this

$object->{"*"}
like image 71
Musa Avatar answered Nov 17 '22 16:11

Musa


Does this work;

  print_r($object->{'*'});
like image 28
Laurence Avatar answered Nov 17 '22 16:11

Laurence


Just

print_r($object->{"*"});
like image 1
Gautam3164 Avatar answered Nov 17 '22 18:11

Gautam3164


You can also convert your object to an array :

$array = get_object_vars($object);
echo $array['*'];

But answers above are even better :

$object->{"*"}
like image 1
Alain Tiemblo Avatar answered Nov 17 '22 18:11

Alain Tiemblo