Welcome Guest, Not a member yet? Register   Sign In
Controllers: private functions
#1

[eluser]Unknown[/eluser]
My question is about private functions used in controllers.

The User Guide states that adding underscore before the name of that function makes the function private, and it won't be accessible via URI:

Code:
private function _somefunction ($first_parameter, $second_parameter) { etc.

And yet, on the same page of the User Guide ("Controllers") there's this example:

Code:
public function _remap ($method) {

Why is the function marked with underscore is declared as public - am I missing something? Is declaring function as public overrules the underscore in its name, or is there any other reason for that? Or perhaps, it's an error in the User Guide?

Thank you!
#2

[eluser]InsiteFX[/eluser]
The underscore used in that example is an internal CI ( underscore ).

The _remap method is declared with the underscore.
#3

[eluser]Aken[/eluser]
CI will treat an opening underscore as a "private" no matter what scope the method is defined under. Or, you can still define a method as private and name it whatever you want and it won't be accessible.

_remap() is a special method used by CI. There's info about it in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB