PHP OOP Interfaces

Program 1

<html>
<head><title>Demo Interface</title></head>
<body>
    <center>
<?php 
     interface Button
     {
           function click();
     }
     interface Key
     {
          function keypress();

     }
     class MyColor implements Button,Key
     {
             function click()
             {
                   echo "<font color=red size=7>Color is Red Now Button <br></font>";
             }
             function keypress()
             {
                echo "<font color=red size=7>Color is Red Now This is Key Press</font>";
             }
     }
     class MyImage implements Button,Key
     {
        function click()
        {
              echo "<img src=dog.jpg >";
       }
       function keypress()
       {
             echo "<img src=dog.jpg  width=50 height=50>";
       }
     }
  
     $M1=new MyColor();
     $M1->click();
     $M1->keypress();
          
?>
</center>
</body>
</html>

Program 2

<html>
<head><title>Demo Interface</title></head>
<body>
    <center>
<?php 
     interface Connect
     {
         
           function connection();
          
     }
 class Oracle implements Connect
 {
    function connection()
    {
        echo "This is Oracle connection";
    }
 }

 class MySql implements Connect
 {
    function connection()
    {
        echo "This is MySql connection";
    }
 }

 class SqlServer implements Connect
 {
    function connection()
    {
        echo "This is Sql server  connection";
    }
 }
       $C1=new SqlServer();
       $C1->connection();
 
?>
</center>
</body>
</html>

 

courses
Image

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *