Welcome Guest, Not a member yet? Register   Sign In
use of $this
#3

(12-02-2016, 08:40 AM)Narf Wrote: If you want to use inheritance - that's its whole purpose.

It can be argued whether inheritance is good in the first place, but since you pretty much can't get without it in CodeIgniter, that's a moot point.

I'm new to OOP and CI and I have two questions here:

1. Is it better to access "$data" the OOP way ("$this->data") as in muuuchos example or should I access it  by "$data" as the CI documentation does, and are the two ways technically equivalent?

2. Then a basic question about inheritance. Lets say I have a class "Car" that inherits "MY_Controller".  Should I access "$data" (or "$this-data") direct or is it better to declare it "private" in "MY_Controller" and then use getter and setter functions? In other words: is it good practice to use data encapsulation when you want to access data from a class that you inherit from?
Reply


Messages In This Thread
use of $this - by muuucho - 12-02-2016, 05:16 AM
RE: use of $this - by Narf - 12-02-2016, 08:40 AM
RE: use of $this - by 040mag - 12-03-2016, 03:23 AM
RE: use of $this - by Narf - 12-03-2016, 08:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB