Monday, 15 September 2014

interface reference to its implemented object in php -



interface reference to its implemented object in php -

i'm trying point interface reference implemented object in php. here's try

here's class:

class business relationship implements fdinterface { public $bal; public function account() { $bal = 0; echo 'account created balance '.$bal; } public function getfdinterest() { echo '</br> involvement rate 9.85'; } }

the interface:

interface fdinterface { public function getfdinterest(); }

and real problem here in index.php

fdinterface fdacc = new account(); // line 1 $fdacc->getfdinterest();

output is

syntax error, unexpected t_string index.php on line 1

you can't utilize fdinterface fdacc = new account();. info type in case interface can utilize parameter in function as:

function callsometing(fdinterface $fdacc) { $fdacc->something(); }

in case, right , functional code is:

$fdacc = new account();

php interface

No comments:

Post a Comment