Yousuf1791

Abstract Class

Jun 22nd, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.27 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class ParentClass{
  4.  
  5.     abstract protected function calc($a, $b);
  6.  
  7. }
  8.  
  9. class ChildClass extends ParentClass{
  10.  
  11.     public function calc($c, $d){ //you can change parameters
  12.         echo $c + $d;
  13.     }
  14.  
  15. }
  16.  
  17. $obj = new ChildClass();
  18.  
  19. $obj->calc(10,20);
  20.  
  21. ?>
Add Comment
Please, Sign In to add comment