Welcome Guest, Not a member yet? Register   Sign In
Adding property in all Contrellers: MY_Controller vs BaseController
#3

Thanks, I fixed the code in OP.

(12-06-2018, 08:13 AM)dave friend Wrote: In case you're interested there are other ways to get the controller.
Here's one way that's a tiny bit more efficient than calling $this->uri->segment(1)
PHP Code:
$this->controller_url config_item('base_url') . $this->router->class

Thanks, I'm going to look into this one. I stil have not played with the router, I'm a novice.  Big Grin

(12-06-2018, 08:13 AM)dave friend Wrote: Or, you could use the PHP magic constant __CLASS__
PHP Code:
$this->controller_url config_item('base_url' __CLASS__

Good point, maybe I could even use

PHP Code:
$this->controller_url config_item('base_url' . static::class; 

in case I extend the controller, the late static binding would do the job and I wouldn't have to declare again in the extended class $this->controller_url = config_item('base_url')  . __CLASS__;  Wink
Reply


Messages In This Thread
RE: Adding property in all Contrellers: MY_Controller vs BaseController - by Balenus - 12-06-2018, 08:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB