Reputation: 1617
I am fairly new to CodeIgniter framework and PHP, and I am trying to figure out what the following source code does:
isset($this->page->data->Metadata->Metadata->View);
From my understanding, isset()
checks if the variable View
is set or not, but what confuses me is that I couldn't find page
class (the location of the .php file that contains View
variable) anywhere in my project folder, nor can I find page
class in the CodeIgniter libraries.
Can someone break down this code, and explain it in detail?
Upvotes: 0
Views: 1202
Reputation: 6994
You should really start to learn basic OOP (Object-Oriented Programming).
The ->
operator in PHP is a way to access member variables and member functions/methods of a class.
$this
referes to the object, in which it's accessed. In your case, I guess, the your controller or model. $this
referes to your controller now.
Now you may wonder, where is page
, because you cannot see it in your controller. Your controller is extending the Base controller of the codeigniter framework and there the member variable page
is definied.
The variable page
itself is an object which has the member variable data
declared and data
holds an object as well and this has the member variable Metadata
and this...
You get the idea, I hope.
And the complete statement checks if a the View
member variable is set on the object stored in the variable Metadata
.
If you didn't understand any of this. You should read the very basics of PHP and OOP in general and in context of PHP! It's worth it. Trust me!
Upvotes: 4