note 124125 added to language.operators.type
| From: | leocavalcante@php.net | Date: | Mon, 19 Aug 2019 03:56:17 +0000 |
| Subject: | note 124125 added to language.operators.type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211948@lists.php.net to get a copy of this message | ||
Note that it fails silently on undeclared classes, it can be hard to catch typos.
<?php declare(strict_types=1);
interface Num {}
class One implements Num {}
class Two implements Num {}
class Three implements Num {}
$n = new Three();
if ($n instanceof One) {
//
} else if ($n instanceof Two) {
//
} else if ($n instanceof Tree) {
// Typo on h
} else {
throw new \Exception("No match");
}
?>
----
Server IP: 208.43.231.9
Probable Submitter: 177.234.144.170 (proxied: 186.220.77.133)
----
Manual Page -- http://php.net/manual/en/language.operators.type.php
Edit -- https://master.php.net/note/edit/124125
Del: integrated -- https://master.php.net/note/delete/124125/integrated
Del: useless -- https://master.php.net/note/delete/124125/useless
Del: bad code -- https://master.php.net/note/delete/124125/bad+code
Del: spam -- https://master.php.net/note/delete/124125/spam
Del: non-english -- https://master.php.net/note/delete/124125/non-english
Del: in docs -- https://master.php.net/note/delete/124125/in+docs
Del: other reasons-- https://master.php.net/note/delete/124125
Reject -- https://master.php.net/note/reject/124125
Search -- https://master.php.net/manage/user-notes.php