Possible duplicate of Reference – What does this symbol mean in PHP?
What does it mean when you have something like this $this->_view->id ?
It is within a class (obviously) and I understand the $this. I get how to use one -> to refer to a property or call a method. But what about when there are two -> in one thing?
The fuller code is:
$viewid = ($this->_view) ? $this->_view->id : null;
I’m guessing the overall gist is: Set $viewid to either (1) the value of $this->_view->id or (2) null, depending on whether $this->_view is TRUE or not. But I don’t get the (1) bit.
Also, is it conventional to use an underscore (_view) to show a property or a method?
Thanks.
This means that there is an object stored within an object.
$this->_view refers to an object called $_view within. So within $_view object $this->id would refer to its $id variable.
So calling $this->_view->id calls for variable $id in an object $_view that is stored in your current object (since you said its $this).
Detailed: