From 141c821c055cda7fe42f909a52440ab5364f0e15 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 23 Apr 2008 03:44:08 +0000 Subject: [PATCH] + Fixed |-- Indentation |-- Markup (missing some s) - Cosmetic (add blank lines in examples) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@258288 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/operators.xml | 53 +++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/language/operators.xml b/language/operators.xml index 207f9039a9..925d4971fe 100644 --- a/language/operators.xml +++ b/language/operators.xml @@ -1,5 +1,5 @@ - + Operators @@ -1192,11 +1192,12 @@ var_dump($a === $b); // bool(false) Using instanceof with classes - - ]]> - - &example.outputs; - +]]> + + &example.outputs; + + + instanceof can also be used to determine whether a variable is an instantiated object of a class that inherits from a parent class: Using instanceof with inherited classes - - ]]> - - &example.outputs; - +]]> + + &example.outputs; + + + To check if an object is not an instanceof a class, the logical not operator can be used. @@ -1255,6 +1262,7 @@ bool(true) class MyClass { } + $a = new MyClass; var_dump(!($a instanceof stdClass)); ?> @@ -1267,29 +1275,33 @@ bool(true) ]]> + + Lastly, instanceof can also be used to determine whether a variable is an instantiated object of a class that implements an interface: Using instanceof for class - - ]]> - - &example.outputs; - +]]> + + &example.outputs; + Using instanceof with other variables - - ]]> +]]> &example.outputs; @@ -1340,7 +1355,7 @@ bool(false) Avoiding classname lookups and fatal errors with instanceof in PHP 5.0 -