|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-06-22 01:55 UTC] php at koteroff dot ru
[2004-07-16 08:40 UTC] helly@php.net
[2004-07-18 02:07 UTC] d at koteroff dot ru
[2004-07-18 02:12 UTC] d at koteroff dot ru
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
Description: ------------ Seems PHP does not support exception catching by parent interface (not by parent classes). Why? This is a very powerful method to classify exceptions in programs. Documentation says that while comparing type in catch block 'instanceof' operator is used, but following test shows that it is wrong. I found corresponding code in the source, zend_execute.c:2866, and it searches for parent classes only. Why not use instanceof_function? Do you have any perspectives about this problem? Can I wrote in my book that PHP will support "interface catching" in the future? Reproduce code: --------------- <? interface E {} class A extends Exception implements E {} try { throw new A(); } catch (E $e) { echo $e; } ?> Expected result: ---------------- prints exception data Actual result: -------------- Fatal error: Uncaught exception