In a controller, I got two functions that one is made to be private:
function toavail(){
$this->autoRender=false;
$result2=$this->__avail();
if($result2==0){return "OK";}
else{return 0;}
}
function __avail(){
$result1=$this->Site1->findByusername('1');
if($result1){
return 1;
}
else{
return 0;
}
}
I am not sure if it is a proper way to access the private function in this case.
You’re accessing it correctly (assuming that both methods are in the same controller class), but in case you’re not aware, your
__avail()method isn’t really private. The double underscore (__) prefix is something of a convention, but it’s only a convention. Your “private” method is really public in actuality. To make it private you need to specify it as such in the signature: