PHP Interfaces are used in Dependency Injections, how then? -


i have seen following code:

class loginauth {     function __construct(authinterface $auth)    {       $this->auth = $auth;    }     function userlogin ($credits)    {       return $this->auth->login($credits);    }  } 

my question interfaces described php is:

 object interfaces allow create code specifies methods class must  implement, without having define how these methods handled.  

so, see interfaces not used define internal logic of [class'] controller, allow definition of methods should implemented class.

how possible that, interface not contain actual logic inside methods, deployed. mean, method login() member of auth() class defined in interface:

interface authinterface () {     function login($credits){} } 

then how such signature used (as used in main example)?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -