Skip to Content
PHPCODE
Type Hinting
oops code / August 12, 2018

<?php

interface test {
public function doSomething();

}
class ABC implements test{
public function doSomething()
{
echo “Doing Something from ABC class”;
}
}
class XYZ implements test {
public function doSomething()
{
echo “Doing Something from XYZ class”;
}
public function doSomethingElse()
{
echo “Doing Something Else.”;
}

}
function test(test $abc)
{
$abc->doSomething();
}
$abc=new XYZ();

test($abc);
?>

PHPCODE © 2024