diff options
Diffstat (limited to 'user_guide/general')
-rw-r--r-- | user_guide/general/controllers.html | 21 | ||||
-rw-r--r-- | user_guide/general/core_classes.html | 8 | ||||
-rw-r--r-- | user_guide/general/creating_libraries.html | 6 | ||||
-rw-r--r-- | user_guide/general/models.html | 12 | ||||
-rw-r--r-- | user_guide/general/styleguide.html | 5 |
5 files changed, 18 insertions, 34 deletions
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 56a1145ad..1d9cd0328 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -330,33 +330,18 @@ called if the URL contains only the sub-folder. Simply name your default contro <p>If you intend to use a constructor in any of your Controllers, you <strong>MUST</strong> place the following line of code in it:</p> -<code>parent::CI_Controller();</code> +<code>parent::__construct();</code> <p>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.</p> - -<p>If you are not familiar with constructors, in PHP 4, a <em>constructor</em> is simply a function that has the exact same name as the class:</p> - -<code> -<?php<br /> -class <kbd>Blog</kbd> extends CI_Controller {<br /> -<br /> - function <kbd>Blog()</kbd><br /> - {<br /> - <var>parent::CI_Controller();</var><br /> - }<br /> -}<br /> -?></code> - -<p>In PHP 5, constructors use the following syntax:</p> - <code> <?php<br /> class <kbd>Blog</kbd> extends CI_Controller {<br /> <br /> function <kbd>__construct()</kbd><br /> {<br /> - <var>parent::CI_Controller();</var><br /> + <var>parent::__construct();</var><br /> + // Your own constructor code<br /> }<br /> }<br /> ?></code> diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html index ac965aee3..35043d9ca 100644 --- a/user_guide/general/core_classes.html +++ b/user_guide/general/core_classes.html @@ -131,9 +131,9 @@ class MY_Input extends CI_Input {<br /><br /> <code> class MY_Input extends CI_Input {<br /> <br /> - function MY_Input()<br /> + function __construct()<br /> {<br /> - parent::CI_Input();<br /> + parent::__construct();<br /> }<br /> }</code> @@ -145,9 +145,9 @@ This allows you to substantially alter the CodeIgniter core.</p> <code>class Welcome extends MY_Controller {<br /> <br /> - function Welcome()<br /> + function __construct()<br /> {<br /> - parent::MY_Controller();<br /> + parent::__construct();<br /> }<br /> <br /> function index()<br /> 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', <kbd>$params</kbd>);</code> <br /> class Someclass {<br /> <br /> - function Someclass($params)<br /> + function __construct($params)<br /> {<br /> // Do something with $params<br /> }<br /> @@ -248,9 +248,9 @@ class MY_Email extends CI_Email {<br /><br /> <code> class MY_Email extends CI_Email {<br /> <br /> - function My_Email()<br /> + function __construct()<br /> {<br /> - parent::CI_Email();<br /> + parent::__construct();<br /> }<br /> }</code> 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 {<br /> var $content = '';<br /> var $date = '';<br /> <br /> - function Blogmodel()<br /> + function __construct()<br /> {<br /> // Call the Model constructor<br /> - parent::CI_Model();<br /> + parent::__construct();<br /> }<br /> <br /> function get_last_ten_entries()<br /> @@ -128,9 +128,9 @@ want this type of organization.</p> <code> class <var>Model_name</var> extends CI_Model {<br /> <br /> - function <var>Model_name</var>()<br /> + function <var>__construct</var>()<br /> {<br /> - parent::CI_Model();<br /> + parent::__construct();<br /> }<br /> }</code> @@ -142,9 +142,9 @@ Make sure your class extends the base Model class.</p> <code> class <var>User_model</var> extends CI_Model {<br /> <br /> - function <var>User_model</var>()<br /> + function <var>__construct</var>()<br /> {<br /> - parent::CI_Model();<br /> + parent::__construct();<br /> }<br /> }</code> 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!"; <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2> <div class="guidelineDetails"> - <p>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.</p> + <p>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.</p> <code><strong>INCORRECT</strong>: class superclass @@ -170,11 +170,10 @@ class SuperClass <strong>CORRECT</strong>: class Super_class</code> - <p>Notice that the Class and constructor methods are identically named and cased:</p> <code>class Super_class { - function Super_class() + function __construct() { } |