|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-03-31 16:38 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-03-31 16:38 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Description: ------------ This might be a 'feature request', a bug or just a documentation issue.. We can use the instanceof operator using variables: i.e. $objectType = 'StdClass' $this instanceof $objectType works flawlessly! But in order to prevent introducing a variable needed just because of the check i would have guessed i could be able to do: $this instanceof get_class($this) (ofcourse the actual usage would be something else, this is just to illustrate the usage of a function to retrieve some type of class name) Test script: --------------- class Foo { function getClass() { return __CLASS__; } } $bar = new Foo(); var_dump($bar instanceof $bar->getClass()); exit; Expected result: ---------------- true Actual result: -------------- Parse error: syntax error, unexpected '('