Gurzi Posted April 24, 2008 Share Posted April 24, 2008 Hello Guys, i defined an interface for my databases and now i have this method in my interface: public function queryUniqueObject($query, $debug ); My problem is that i alwasy done without interfaces this methodas as public function queryUniqueObject($query, $debug = false ); If now i try to use this last method in the class that implements the interface, it says that it has to be like that ( interface ). But in the interface, it doesn't let me put the method like $debug= false. Why ? how can i solve this ? because i really dont want to modify my entire code. Link to comment https://forums.phpfreaks.com/topic/102642-interfaces-doubt/ Share on other sites More sharing options...
Daniel0 Posted April 24, 2008 Share Posted April 24, 2008 What do you mean with that it doesn't allow you to set a default value for the $debug argument? Are you sure you even need an interface? What are you using it for? Link to comment https://forums.phpfreaks.com/topic/102642-interfaces-doubt/#findComment-526096 Share on other sites More sharing options...
aschk Posted April 25, 2008 Share Posted April 25, 2008 The following works fine for me: <?php interface test { public function method($var, $var1 = false); } class example implements test { public function method($var, $var1 = false){ // do something } } ?> So, as you can see you CAN have a method in an interface that implements a default value inside the method call. Where's the real problem? What error are you getting? Can you post the relevant code? Link to comment https://forums.phpfreaks.com/topic/102642-interfaces-doubt/#findComment-526935 Share on other sites More sharing options...
Gurzi Posted April 29, 2008 Author Share Posted April 29, 2008 The following works fine for me: <?php interface test { public function method($var, $var1 = false); } class example implements test { public function method($var, $var1 = false){ // do something } } ?> So, as you can see you CAN have a method in an interface that implements a default value inside the method call. Where's the real problem? What error are you getting? Can you post the relevant code? It said that i cannot have values defined in interface arguments list. Link to comment https://forums.phpfreaks.com/topic/102642-interfaces-doubt/#findComment-529251 Share on other sites More sharing options...
Daniel0 Posted April 29, 2008 Share Posted April 29, 2008 Try to run aschk's code and see if it works (I don't see any reason why it shouldn't). And then post your code along with the error message verbatim. Link to comment https://forums.phpfreaks.com/topic/102642-interfaces-doubt/#findComment-529347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.