My problem is this.
A function return an object, and I want to access its property. It throws and error when I try to do it like this
$this->FunctionThatReturnsAnObject()->Property;
Right now I’m creating a new variable and taking the property from it, like this:
$newVar=$this->FunctionThatReturnsAnObject();
$property=$newVar->Property;
Is this the right way of doing this?
This works perfectly fine in modern PHP versions.
If you’re experiencing an error, we’ll need to know what the error is. As mentioned in the comments, you might not be able to do this in PHP4, but you shouldn’t be using PHP4 in the modern era to begin with. As long as the instance method you’re calling returns an object, you can operate on that object directly. (You can’t do this from a constructor right now:
new Foo()->functionThatReturnsAnObject()will not work because the PHP internals team is full of people that think this would be confusing in some way. I’m not making this up.)