diff options
Diffstat (limited to 'user_guide_src/source/general')
-rw-r--r-- | user_guide_src/source/general/ancillary_classes.rst | 38 | ||||
-rw-r--r-- | user_guide_src/source/general/core_classes.rst | 12 | ||||
-rw-r--r-- | user_guide_src/source/general/creating_libraries.rst | 38 |
3 files changed, 44 insertions, 44 deletions
diff --git a/user_guide_src/source/general/ancillary_classes.rst b/user_guide_src/source/general/ancillary_classes.rst index a4befc7b3..5dc058ad4 100644 --- a/user_guide_src/source/general/ancillary_classes.rst +++ b/user_guide_src/source/general/ancillary_classes.rst @@ -58,30 +58,30 @@ won't need to call ``get_instance()`` in every single method. Example:: -class Example { + class Example { - protected $CI; + protected $CI; - // We'll use a constructor, as you can't directly call a function - // from a property definition. - public function __construct() - { - // Assign the CodeIgniter super-object - $this->CI =& get_instance(); - } + // We'll use a constructor, as you can't directly call a function + // from a property definition. + public function __construct() + { + // Assign the CodeIgniter super-object + $this->CI =& get_instance(); + } - public function foo() - { - $this->CI->load->helper('url'); - redirect(); - } + public function foo() + { + $this->CI->load->helper('url'); + redirect(); + } - public function bar() - { - $this->CI->config_item('base_url'); - } + public function bar() + { + $this->CI->config_item('base_url'); + } -} + } In the above example, both methods ``foo()`` and ``bar()`` will work after you instantiate the Example class, without the need to call diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst index ce57aeef0..07c0b00ba 100644 --- a/user_guide_src/source/general/core_classes.rst +++ b/user_guide_src/source/general/core_classes.rst @@ -76,15 +76,15 @@ application/core/MY_Input.php, and declare your class with:: } .. note:: If you need to use a constructor in your class make sure you -extend the parent constructor:: + extend the parent constructor:: - class MY_Input extends CI_Input { + class MY_Input extends CI_Input { - public function __construct() - { - parent::__construct(); + public function __construct() + { + parent::__construct(); + } } - } **Tip:** Any functions in your class that are named identically to the methods in the parent class will be used instead of the native ones diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst index 8bafd4532..4fc8ed72f 100644 --- a/user_guide_src/source/general/creating_libraries.rst +++ b/user_guide_src/source/general/creating_libraries.rst @@ -148,30 +148,30 @@ take full advantage of the OOP principles. So, in order to be able to use the CodeIgniter super-object in all of the class methods, you're encouraged to assign it to a property instead:: -class Example_library { + class Example_library { - protected $CI; + protected $CI; - // We'll use a constructor, as you can't directly call a function - // from a property definition. - public function __construct() - { - // Assign the CodeIgniter super-object - $this->CI =& get_instance(); - } + // We'll use a constructor, as you can't directly call a function + // from a property definition. + public function __construct() + { + // Assign the CodeIgniter super-object + $this->CI =& get_instance(); + } - public function foo() - { - $this->CI->load->helper('url'); - redirect(); - } + public function foo() + { + $this->CI->load->helper('url'); + redirect(); + } - public function bar() - { - echo $this->CI->config_item('base_url'); - } + public function bar() + { + echo $this->CI->config_item('base_url'); + } -} + } Replacing Native Libraries with Your Versions ============================================= |