|
|
Tutorials » Php »
|
Topic |
What are the Type Operator?
|
|
Explanation |
|
The only PHP type operator: instanceof is used to determine whether a given object,
its parents or their implemented interfaces are of a specified object class.Before this is_a() was used but is_a()
has been deprecated in favor of instanceof.
Example
<?php
class A { }
class B { }
$like = new A;
if ($like instanceof A)
{
echo 'A';
}
if ($like instanceof B)
{
echo 'B';
}
?>
Result:
A
In the above example like is an object of class A, so "A" is displayed as answer
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|