Welcome Guest, Not a member yet? Register   Sign In
Super object is Pages or Controller.php?
#1

Hi. I just started reading the tutorial and it says:

Quote:Create a file at application/controllers/pages.php. The pages class is extending the CI_Controller class. This means that the new pages class can access the methods and variables defined in the CI_Controller class (system/core/Controller.php).

The controller is what will become the center of every request to your web application. In very technical CodeIgniter discussions, it may be referred to as the super object. Like any php class, you refer to it within your controllers as $this.

Here $this is controller.php or pages.php? I understand that $this is the Controller.php and I will refer to it as $this when using its methods in pages.php. I just want to double check because pages.php and Controller.php are both controllers.
Reply
#2

since pages extends the CI_Controller, it's also a controller which inherits its parents methods. So, $this is the controller when in CI_Controller, and also any other controller that extends CI_Controller.
Reply
#3

[quote]So, $this is the controller when in CI_Controller, and also any other controller that extends CI_Controller.[quote]

Im talking about this particular case thats why I quoted tutorial, not a general definition of $this.

So when I say $this it means both Pages.php and Controler.php? If I want to use a Controller.php's method within Pages.php I will refer to Controller.php as $this, but you are saying that whenever I say $this I will be referring to both Controller.php and Pages.php - that doesnt make sense because $this can only be referred to one class.
Reply
#4

Ok, nvrmnd I figure it out. I just had to re-read lol thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB