Advertisement
Yousuf1791

interface

Jun 17th, 2023
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. interface parentClass1{
  4.  
  5.     function calc($a, $b); //Can not set access modifier
  6.  
  7. }
  8.  
  9. interface parentClass2{
  10.  
  11.     function sub($c, $d);
  12.  
  13. }
  14.  
  15. class childClass implements parentClass1, parentClass2{
  16.  
  17.     public function calc($a, $b){
  18.  
  19.         echo $a + $b;
  20.  
  21.     }
  22.  
  23.     public function sub($c, $d){
  24.  
  25.         echo $c - $d;
  26.  
  27.     }
  28.  
  29. }
  30.  
  31. $test = new childClass();
  32.  
  33. $test->calc(20,35);
  34. echo "<br>";
  35.  
  36. $test->sub(75, 30);
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement