summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--user_guide_src/source/general/core_classes.rst29
-rw-r--r--user_guide_src/source/general/creating_libraries.rst55
-rw-r--r--user_guide_src/source/general/drivers.rst3
-rw-r--r--user_guide_src/source/general/errors.rst11
4 files changed, 84 insertions, 14 deletions
diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst
index 8cd3a93dc..ac41407f7 100644
--- a/user_guide_src/source/general/core_classes.rst
+++ b/user_guide_src/source/general/core_classes.rst
@@ -50,7 +50,9 @@ instead of the one normally used.
Please note that your class must use CI as a prefix. For example, if
your file is named Input.php the class will be named::
- class CI_Input { }
+ class CI_Input {
+
+ }
Extending Core Class
====================
@@ -68,12 +70,20 @@ couple exceptions:
For example, to extend the native Input class you'll create a file named
application/core/MY_Input.php, and declare your class with::
- class MY_Input extends CI_Input { }
+ class MY_Input extends CI_Input {
+
+ }
Note: If you need to use a constructor in your class make sure you
extend the parent constructor::
- class MY_Input extends CI_Input {     function __construct()     {         parent::__construct();     } }
+ class MY_Input extends CI_Input {
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+ }
**Tip:** Any functions in your class that are named identically to the
functions in the parent class will be used instead of the native ones
@@ -85,7 +95,18 @@ your new class in your application controller's constructors.
::
- class Welcome extends MY_Controller {     function __construct()     {         parent::__construct();     }     function index()     {         $this->load->view('welcome_message');     } }
+ class Welcome extends MY_Controller {
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function index()
+ {
+ $this->load->view('welcome_message');
+ }
+ }
Setting Your Own Prefix
-----------------------
diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst
index d322f56eb..bc545b483 100644
--- a/user_guide_src/source/general/creating_libraries.rst
+++ b/user_guide_src/source/general/creating_libraries.rst
@@ -45,7 +45,16 @@ The Class File
Classes should have this basic prototype (Note: We are using the name
Someclass purely as an example)::
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Someclass {     public function some_function()     {     } } /* End of file Someclass.php */
+ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+ class Someclass {
+
+ public function some_function()
+ {
+ }
+ }
+
+ /* End of file Someclass.php */
Using Your Class
================
@@ -70,12 +79,24 @@ In the library loading function you can dynamically pass data as an
array via the second parameter and it will be passed to your class
constructor::
- $params = array('type' => 'large', 'color' => 'red'); $this->load->library('Someclass', $params);
+ $params = array('type' => 'large', 'color' => 'red');
+
+ $this->load->library('Someclass', $params);
If you use this feature you must set up your class constructor to expect
data::
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Someclass {     public function __construct($params)     {         // Do something with $params     } } ?>
+ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+ class Someclass {
+
+ public function __construct($params)
+ {
+ // Do something with $params
+ }
+ }
+
+ ?>
You can also pass parameters stored in a config file. Simply create a
config file named identically to the class file name and store it in
@@ -93,7 +114,10 @@ object.
Normally from within your controller functions you will call any of the
available CodeIgniter functions using the $this construct::
- $this->load->helper('url'); $this->load->library('session'); $this->config->item('base_url'); etc.
+ $this->load->helper('url');
+ $this->load->library('session');
+ $this->config->item('base_url');
+ // etc.
$this, however, only works directly within your controllers, your
models, or your views. If you would like to use CodeIgniter's classes
@@ -106,7 +130,12 @@ First, assign the CodeIgniter object to a variable::
Once you've assigned the object to a variable, you'll use that variable
*instead* of $this::
- $CI =& get_instance(); $CI->load->helper('url'); $CI->load->library('session'); $CI->config->item('base_url'); etc.
+ $CI =& get_instance();
+
+ $CI->load->helper('url');
+ $CI->load->library('session');
+ $CI->config->item('base_url');
+ // etc.
.. note:: You'll notice that the above get_instance() function is being
passed by reference::
@@ -126,7 +155,9 @@ same as the native library. For example, to replace the native Email
library you'll create a file named application/libraries/Email.php, and
declare your class with::
- class CI_Email { }
+ class CI_Email {
+
+ }
Note that most native classes are prefixed with CI\_.
@@ -153,12 +184,20 @@ couple exceptions:
For example, to extend the native Email class you'll create a file named
application/libraries/MY_Email.php, and declare your class with::
- class MY_Email extends CI_Email { }
+ class MY_Email extends CI_Email {
+
+ }
Note: If you need to use a constructor in your class make sure you
extend the parent constructor::
- class MY_Email extends CI_Email {     public function __construct()     {         parent::__construct();     } }
+ class MY_Email extends CI_Email {
+
+ public function __construct()
+ {
+ parent::__construct();
+ }
+ }
Loading Your Sub-class
----------------------
diff --git a/user_guide_src/source/general/drivers.rst b/user_guide_src/source/general/drivers.rst
index 8d0d84aaa..e2ded62e2 100644
--- a/user_guide_src/source/general/drivers.rst
+++ b/user_guide_src/source/general/drivers.rst
@@ -30,7 +30,8 @@ Methods of that class can then be invoked with::
The child classes, the drivers themselves, can then be called directly
through the parent class, without initializing them::
- $this->some_parent->child_one->some_method(); $this->some_parent->child_two->another_method();
+ $this->some_parent->child_one->some_method();
+ $this->some_parent->child_two->another_method();
Creating Your Own Drivers
=========================
diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst
index 0764e9db8..91b59140f 100644
--- a/user_guide_src/source/general/errors.rst
+++ b/user_guide_src/source/general/errors.rst
@@ -54,7 +54,16 @@ one of three "levels" in the first parameter, indicating what type of
message it is (debug, error, info), with the message itself in the
second parameter. Example::
- if ($some_var == "") {     log_message('error', 'Some variable did not contain a value.'); } else {     log_message('debug', 'Some variable was correctly set'); } log_message('info', 'The purpose of some variable is to provide some value.');
+ if ($some_var == "")
+ {
+ log_message('error', 'Some variable did not contain a value.');
+ }
+ else
+ {
+ log_message('debug', 'Some variable was correctly set');
+ }
+
+ log_message('info', 'The purpose of some variable is to provide some value.');
There are three message types: