From a7056988f0f54975ae479c8ea0edf27f0dc9c880 Mon Sep 17 00:00:00 2001
From: Pascal Kriete If you intend to use a constructor in any of your Controllers, you MUST place the following line of code in it: 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: In PHP 5, constructors use the following syntax:parent::CI_Controller();
+parent::__construct();
-<?php
-
-
-class Blog extends CI_Controller {
-
- function Blog()
- {
- parent::CI_Controller();
- }
-}
-?>
<?php
diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html
index d7c2d16e7..6846b78e7 100644
--- a/user_guide/helpers/smiley_helper.html
+++ b/user_guide/helpers/smiley_helper.html
@@ -101,9 +101,9 @@ your smiley folder.
class Blog extends CI_Controller {
@@ -357,6 +341,7 @@ class Blog extends CI_Controller {
function __construct()
{
parent::CI_Controller();
+ // Your own constructor code
}
}
?>
class MY_Input extends CI_Input {
- function MY_Input()
+ function __construct()
{
- parent::CI_Input();
+ parent::__construct();
}
}
@@ -145,9 +145,9 @@ This allows you to substantially alter the CodeIgniter core.
class Welcome extends MY_Controller {
- function Welcome()
+ function __construct()
{
- parent::MY_Controller();
+ parent::__construct();
}
function index()
diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html
index 3f0e32cb0..00d0f4aa4 100644
--- a/user_guide/general/creating_libraries.html
+++ b/user_guide/general/creating_libraries.html
@@ -141,7 +141,7 @@ $this->load->library('Someclass', $params);
class MY_Email extends CI_Email {
- function My_Email()
+ function __construct()
{
- parent::CI_Email();
+ parent::__construct();
}
}
diff --git a/user_guide/general/models.html b/user_guide/general/models.html
index 35ab08d20..466996648 100644
--- a/user_guide/general/models.html
+++ b/user_guide/general/models.html
@@ -83,10 +83,10 @@ class Blogmodel extends CI_Model {
class Model_name extends CI_Model {
- function Model_name()
+ function __construct()
{
- parent::CI_Model();
+ parent::__construct();
}
}
@@ -142,9 +142,9 @@ Make sure your class extends the base Model class.
class User_model extends CI_Model {
- function User_model()
+ function __construct()
{
- parent::CI_Model();
+ parent::__construct();
}
}
diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html
index 7b7d837d9..f30f45529 100644
--- a/user_guide/general/styleguide.html
+++ b/user_guide/general/styleguide.html
@@ -161,7 +161,7 @@ echo "Here's my code!";
Class names should always have their first letter uppercase, and the constructor method should match identically. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.
+Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.
INCORRECT:
class superclass
@@ -170,11 +170,10 @@ class SuperClass
CORRECT:
class Super_class
- Notice that the Class and constructor methods are identically named and cased:
class Super_class {
- function Super_class()
+ function __construct()
{
}
diff --git a/user_guide/installation/upgrade_200.html b/user_guide/installation/upgrade_200.html
index fa57dfb25..16c7d8d3b 100644
--- a/user_guide/installation/upgrade_200.html
+++ b/user_guide/installation/upgrade_200.html
@@ -100,13 +100,16 @@ to
Please read how to use this method in the Encryption library documentation.
-
+Step 5: Remove loading calls for the compatibility helper.
+The compatibility helper has been removed from the CodeIgniter core. All methods in it should be natively available in supported PHP versions.
-Step 5: Update Class extension
+Step 6: Update Class extension
All core classes are now prefixed with CI_. Update Models and Controllers to extend CI_Model and CI_Controller, respectively.
+Step 7: Update Parent Constructor calls
+All native CodeIgniter classes now use the PHP 5 __construct() convention. Please update extended libraries to call parent::__construct().
-Step 6: Update your user guide
+Step 8: Update your user guide
Please replace your local copy of the user guide with the new version, including the image files.