fixing code spacing in Core, Library, Drivers, and Errors general docs
diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst
index 8cd3a93..ac41407 100644
--- a/user_guide_src/source/general/core_classes.rst
+++ b/user_guide_src/source/general/core_classes.rst
@@ -50,7 +50,9 @@
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 @@
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 @@
::
- 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 d322f56..bc545b4 100644
--- a/user_guide_src/source/general/creating_libraries.rst
+++ b/user_guide_src/source/general/creating_libraries.rst
@@ -45,7 +45,16 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 8d0d84a..e2ded62 100644
--- a/user_guide_src/source/general/drivers.rst
+++ b/user_guide_src/source/general/drivers.rst
@@ -30,7 +30,8 @@
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 0764e9d..91b5914 100644
--- a/user_guide_src/source/general/errors.rst
+++ b/user_guide_src/source/general/errors.rst
@@ -54,7 +54,16 @@
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: