From a7056988f0f54975ae479c8ea0edf27f0dc9c880 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Wed, 10 Nov 2010 16:12:55 -0500 Subject: some doc fixes to show __construct instead of CI_Controller --- user_guide/general/controllers.html | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'user_guide/general/controllers.html') diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 56a1145ad..bcd0e4bce 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -330,26 +330,10 @@ called if the URL contains only the sub-folder. Simply name your default contro

If you intend to use a constructor in any of your Controllers, you MUST place the following line of code in it:

-parent::CI_Controller(); +parent::__construct();

The reason this line is necessary is because your local constructor will be overriding the one in the parent controller class so we need to manually call it.

- -

If you are not familiar with constructors, in PHP 4, a constructor is simply a function that has the exact same name as the class:

- - -<?php
-class Blog extends CI_Controller {
-
-       function Blog()
-       {
-            parent::CI_Controller();
-       }
-}
-?>
- -

In PHP 5, constructors use the following syntax:

- <?php
class Blog extends CI_Controller {
@@ -357,6 +341,7 @@ class Blog extends CI_Controller {
       function __construct()
       {
            parent::CI_Controller();
+            // Your own constructor code
       }
}
?>
-- cgit v1.2.3-24-g4f1b