PHP OOP Abstract Classes
by TechVidvan Team
Program 1
<html>
<head><title>Demo</title></head>
<body>
<center>
<?php
abstract class Base
{
abstract function display();
}
class Derived extends Base
{
function display()
{
echo "This is display of Derived";
}
}
class Derived1 extends Base
{
function display()
{
echo "This is display of Derived one class";
}
}
$d=new Derived1();
$d->display();
?>
</center>
</body>
</html>Program 2
<html>
<head><title>Demo</title></head>
<body>
<center>
<?php
abstract class Button
{
abstract function click();
}
class MyColor extends Button
{
function click()
{
echo "<font color=red size=7>Color is Red Now</font>";
}
}
class MyImage extends Button
{
function click()
{
echo "<img src=dog.jpg>";
}
}
$M=new MyImage();
$M->click();
?>
</center>
</body>
</html>
Tags: abstract class in phpoops abstract class in phpPHPphp abstract classphp oops abstract classphp practicalphp program
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.