The interface declares what methods a class must have without having to implement them. Any class that implements the interface will have to implement details of those declared methods. Interface is not a class, so you can not instantiate an interface. It is useful when you need to enforce some classes to do something.
<?php
interface A {
public function setProperty($x);
public function description();
}
class Property implements A {
public function setProperty($x) {
$this->x = $x;
}
public function description() {
echo "Counting" . $this->x . plot;
}
}
$property = new Property();
$property->setProperty(Garden);
$property->description();
?>
Output:
Counting Garden plot
<?php
interface A {
public function Compute();
}
interface B extends A {
public function Divide();
}
class C implements B {
public function Divide() {
$var=10;
$var1=2;
$var3=$var/$var1;
echo “division of 10/2 is” . $var3;
}
public function Compute() {
$a=2;
$b=3;
$c=$a*$b;
echo “multiplication of 2*3 is” . $c;
}
}
$obj = new C();
$obj->Divide();
$obj->Compute();
?>
Output:
division of 10/2 is 5
multiplication of 2*3 is 6
Interfaces Important Point:-
© 2025 Easy To Learning. All Rights Reserved | Design by Easy To Learning