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

If print_r($object)returns

stdClass Object
(
    [*] => sometext
)

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

+5
source share
4 answers

You can access this property.

$object->{"*"}
+9
source

It works,

  print_r($object->{'*'});
+2
source

Simply

print_r($object->{"*"});
+1
source

You can also convert your object to an array:

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

But the answers above are even better:

$object->{"*"}
+1
source

All Articles