Commits

Eric Barnes committed 626d1f0

Fixed missing parentheses and added scope to examples. Fixes #103

Comments (0)

Files changed (1)

user_guide/general/controllers.html

 <?php
 class Blog extends CI_Controller {
 
-	function index()
+	public function index()
 	{
 		echo 'Hello World!';
 	}
 <?php
 class Blog extends CI_Controller {
 
-	function index()
+	public function index()
 	{
 		echo 'Hello World!';
 	}
 
-	function comments()
+	public function comments()
 	{
 		echo 'Look at this!';
 	}
 &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 />
 <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>
 
 <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 />
 
 <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 />
 <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>
 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>
 &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 />