CodeIgniter Forums
Codeigniter 3.0 RC issue with not calling __construct when no method matching - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Codeigniter 3.0 RC issue with not calling __construct when no method matching (/showthread.php?tid=975)



Codeigniter 3.0 RC issue with not calling __construct when no method matching - sandeepmittal88 - 02-02-2015

Hi,

We have recently updated to Codeigniter 3.0 RC and got one issue.

We have one controller which have only constructor function. It check uri segment and redirect to another url. It was working fine in last version but i have checked that now it not calling constructor if matching function not present, it directly look for function in controller first if present then call the controller constructor.

I have used alternative to make a function in controller and then add a route in route.config. Can you please help why earlier approach not working.

class Shorturl extends CI_Controller {

public function __construct()
{
parent::__construct();

$url = trim($this->security->xss_clean($this->uri->segment(2)));
redirect($url,'location',301);
}
}


RE: Codeigniter 3.0 RC issue with not calling __construct when no method matching - Narf - 02-02-2015

(02-02-2015, 10:41 AM)sandeepmittal88 Wrote: ...
why earlier approach not working
...

Because it's a wrong approach. No instantiated class should ever contain only a constructor.