How to Extended class in PHP
How to Extended class in PHP
An extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'. This is also called a "parent-child" relationship. You create a class, parent, and use extends to create a new class based on the parent class: the child class.
12345678910111213141516171819202122232425262728<html>
<head>
<title>The Shape of Things to Come</title>
</head>
<body>
<p>
<?php
class Shape {
public $hasSides = true;
}
class Square extends Shape
{
public $hassides = true;
}
$square = new Square();
// Add your code below!
if (property_exists($square, "hassides"))
{
echo "I have sides!";
}
?>
</p>
</body>
</html>
How to Extended class in PHP
Reviewed by Rajat Jha
on
23:34:00
Rating:
Most Welcome, Thanks for support
ReplyDelete