summaryrefslogtreecommitdiffstats
path: root/user_guide/general/controllers.html
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-03-11 11:17:25 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-03-11 11:17:25 +0100
commit2d927761f13489187db6ae34a7c0a52367779de4 (patch)
tree4163cb591164af2279f389bb561258b68a1d1032 /user_guide/general/controllers.html
parent52e73183c2d3723c12a0a711d604f9f42f8e7b2b (diff)
parentf21a4649afaf4726c8b2feb36dcec9e4fbd95661 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter-Reactor
Diffstat (limited to 'user_guide/general/controllers.html')
-rw-r--r--user_guide/general/controllers.html22
1 files changed, 11 insertions, 11 deletions
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html
index ccc5302f8..2da98b6c7 100644
--- a/user_guide/general/controllers.html
+++ b/user_guide/general/controllers.html
@@ -98,7 +98,7 @@ Controllers
&lt;?php
class Blog extends CI_Controller {
- function index()
+ public function index()
{
echo 'Hello World!';
}
@@ -153,12 +153,12 @@ class <var>blog</var> extends CI_Controller {<br />
&lt;?php
class Blog extends CI_Controller {
- function index()
+ public function index()
{
echo 'Hello World!';
}
- function comments()
+ public function comments()
{
echo 'Look at this!';
}
@@ -187,7 +187,7 @@ class Blog extends CI_Controller {
&lt;?php<br />
class Products extends CI_Controller {<br />
<br />
-&nbsp;&nbsp;&nbsp;&nbsp;function shoes($sandals, $id)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;public function shoes($sandals, $id)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $sandals;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $id;<br />
@@ -220,7 +220,7 @@ specifying any URI segments you'll see your Hello World message by default.</p>
<p>As noted above, the second segment of the URI typically determines which function in the controller gets called.
CodeIgniter permits you to override this behavior through the use of the <kbd>_remap()</kbd> function:</p>
-<code>function _remap()<br />
+<code>public function _remap()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Some code here...<br />
}</code>
@@ -231,7 +231,7 @@ allowing you to define your own function routing rules.</p>
<p>The overridden function call (typically the second segment of the URI) will be passed as a parameter to the <kbd>_remap()</kbd> function:</p>
-<code>function _remap(<var>$method</var>)<br />
+<code>public function _remap(<var>$method</var>)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ($method == 'some_method')<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
@@ -245,10 +245,10 @@ allowing you to define your own function routing rules.</p>
<p>Any extra segments after the method name are passed into <kbd>_remap()</kbd> as an optional second parameter. This array can be used in combination with PHP's <a href="http://php.net/call_user_func_array">call_user_func_array</a> to emulate CodeIgniter's default behavior.</p>
-<code>function _remap($method, $params = array())<br />
+<code>public function _remap($method, $params = array())<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;$method = 'process_'.$method;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;if (method_exists($this, $method)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;if (method_exists($this, $method))<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return call_user_func_array(array($this, $method), $params);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
@@ -270,7 +270,7 @@ be called by the output class instead of echoing the finalized data directly. Th
<p>Here is an example:</p>
<code>
-function _output($output)<br />
+public function _output($output)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $output;<br />
}</code>
@@ -298,7 +298,7 @@ the available methods in the <a href="../libraries/output.html">Output Class</a>
underscore as the name prefix and it will not be served via a URL request. For example, if you were to have a function like this:</p>
<code>
-function _utility()<br />
+private function _utility()<br />
{<br />
&nbsp;&nbsp;// some code<br />
}</code>
@@ -346,7 +346,7 @@ called if the URL contains only the sub-folder. Simply name your default contro
&lt;?php<br />
class <kbd>Blog</kbd> extends CI_Controller {<br />
<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function <kbd>__construct()</kbd><br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public function <kbd>__construct()</kbd><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<var>parent::__construct();</var><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your own constructor code<br />