0

I am declaring functions in interface but as soon as i add a new function in already completed module it gives me an error. The module which was working properly stops working.

interface iBoqCart{
public function add_toCart($item_id,$cqty,$user_id,$uniqid);
public function all_cartDatas($user_id);
public function delCart($cart_id);//delete cart 
public function dellAllCart($user_id);
public function allCart();
public function new_function(); // this is my new function if i remove it my previous module in application starts working.
}

As i am new in OOP i am not display proper error, i am displaying error from client side.

5
  • Can you please share the error with us? Commented Jun 16, 2017 at 17:53
  • I'd say that when you add a new 'function' to an interface, you have to code behaviour to it in any class that implements said interface. Commented Jun 16, 2017 at 17:53
  • Post the error message. But I'll wager that the error is that while you've added the method to the interface, you haven't updated all the classes that implement the interface with an implementation of the new method. Commented Jun 16, 2017 at 17:53
  • I am displaying error in a normal way, don't have enough knowledge in oop to display error i am just displaying error with error: function(){eMsg('195');} Commented Jun 16, 2017 at 17:57
  • Can you help in displaying the error, I am using ajax to call the pages Commented Jun 16, 2017 at 18:01

1 Answer 1

1

First of all, you need to develop an understanding of OOP before implementing it because you are going to trip over every single hurdle along the way otherwise which makes for an incredibly unpleasant experience.

Classes that implement interfaces MUST declare the functions in that interface, if any class misses any of the declared functions, it will throw an Exception.

Sign up to request clarification or add additional context in comments.

2 Comments

While your commentary is correct, the author needs to learn OOP principles, this is his way of doing so. We have no way of knowing how pleasant (or not) his experience is.
@AndyJones I am not convinced asking questions on here every time you get stuck is the best or most productive way of learning something new (this community really isn't the best for that kind of thing).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.