sasori Posted August 9, 2008 Share Posted August 9, 2008 i creadted this test script and saved as interface.dbdriver.php <?php /** * @author rmbapc * @copyright 2008 */ //interfaced.dbdriver.php interface DBDriver { public function connect(); public function execute($sql); } ?> and then i created another file and saved as class.mysqldriver.php <?php /** * @author rmbapc * @copyright 2008 */ //class.mysqldriver.php include("interface.dbdriver.php"); class MySQLDriver implements DBDriver { } ?> i tried to run the class.mysqldriver.php and the error says Fatal error: Class MySQLDriver contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (DBDriver::connect, DBDriver::execute) in C:\wamp\www\test2\oop\class.mysqldriver.php on line 12 now my question is, "why does the error says, 2 abstract methods?" when infact i made an interface and not an abstract right? Link to comment https://forums.phpfreaks.com/topic/118867-solved-interface-help/ Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 In order for an interface to work, you must provide an implementation of every method in the interface in any class that implements it. >_> Basically MySQL driver NEEDS a connect() and execute($sql) method of equal or greater visibility. Link to comment https://forums.phpfreaks.com/topic/118867-solved-interface-help/#findComment-612125 Share on other sites More sharing options...
sasori Posted August 9, 2008 Author Share Posted August 9, 2008 In order for an interface to work, you must provide an implementation of every method in the interface in any class that implements it. >_> Basically MySQL driver NEEDS a connect() and execute($sql) method of equal or greater visibility. ok cool..very well said. thanks Link to comment https://forums.phpfreaks.com/topic/118867-solved-interface-help/#findComment-612130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.