0

i have a class like this:

class Asd{

function index(){
$this->doSomenthing();

}

function doSomenthing(){

}

}

i'm using codeigniter so doSomenthing == http://www.site.com/asd/dosomenthing;

i would like to leave that method as "private" it can be used but not accessed by http requests, it should be used only from the other methods inside the class.

Does i need to declare that method as private function doSomenthing(){} ?

0

1 Answer 1

4

you can prefix the "doSomething"-method with an underscore. That way it wont be accessed via the URL request.

http://codeigniter.com/user_guide/general/controllers.html#private

Sign up to request clarification or add additional context in comments.

5 Comments

Thats CodeIgniter implementation
Just declaring it as private is enough in codeigniter. No need for remap.
i used private function _doSomenthing() but i receive the error: Parse error: syntax error, unexpected T_PRIVATE
@itachi but i receive error Parse error: syntax error, unexpected T_PRIVATE
It is a parse error. It can be due to anything. Post the whole controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.