Is it possible to restrict how a method can be called in PHP?
        Posted  
        
            by Ashley Ward
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ashley Ward
        
        
        
        Published on 2010-06-16T14:50:14Z
        Indexed on 
            2010/06/16
            14:52 UTC
        
        
        Read the original article
        Hit count: 215
        
Given that my class looks like this:
class Methods{
function a(){
return 'a';
}
function b(){
$this->a();
}
function c(){
$this->a();
}
}
Is it possible to ensure that function a can only be called from function b?
In the above example function c should fail. I could just include it in function b, but in the future I may want to let a() be called by some new functions (e.g. d() or e())
© Stack Overflow or respective owner