should i use Classname() or __construct() as constructor in CodeIgniter?
both work, which should i use?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Classname()is the old way (i.e. PHP 4 way).__construct()is the new (i.e. PHP 5) way.You should use the second one, if your application is written with PHP 5 — and you should write your applications with PHP 5 in mind !
See the Constructors and Destructors section in the manual, which states (quoting) :