PHP Scripting
Instance of
instance of in object oriented format and is_a example in PHP
By Geekboots
6/4/2020
0 views
instance-of.phpPHP
<?php
class employee {
private $empId;
private $name;
function __construct($empId,$name) {
$this->name = $empId;
$this->age = $name;
}
}
$emp = new employee("EP20", "Ajoy");
/* Check the object is a instance of the class or not using 'instanceof' */
if($emp instanceof employee)
echo "\$emp is a object of employee class - instanceof<br />";
/* Check the object is a instance of the class or not using 'is_a' */
if(is_a($emp, employee))
echo "\$emp is a object of employee class - is_a()";
?>
/* Output */
$emp is a object of employee class - instanceof
$emp is a object of employee class - is_a()
PHPinstance of in PHPis_a in PHPPHP tutorial