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?
You are a little confused
Tries to call the method get_customer() on what gettype returns. (A string isn’t an object)
Basically, if you want to create an object, and then call a method on it, you have to do it on two separate lines.
This no worky:
This worky: