PHP object help -> unexpected T_OBJECT_OPERATOR

Posted by php-b-grader on Stack Overflow See other posts from Stack Overflow or by php-b-grader
Published on 2010-05-28T05:44:29Z Indexed on 2010/05/28 5:51 UTC
Read the original article Hit count: 167

Filed under:
|
|

Please help me understand:

print gettype(new CustomerObject()) 

prints: "object" (so it is an object)

BUT

print gettype((new CustomerObject())->get_customer());

prints: unexpected T_OBJECT_OPERATOR

If I do it over two lines it works fine

$object = new Customer($order->customer_id);
print gettype($object);

prints: object

$customer = $object->get_customer();
print gettype($customer);

prints: array

It appears that the lines cannot be joined into a single call. Is this correct? and what is the logic behind that?

© Stack Overflow or respective owner

Related posts about php

Related posts about objects