Doc #70421 [Asn->Csd]: Inconsistant constant errors

From: Date: Sun, 06 Sep 2015 17:03:06 +0000
Subject: Doc #70421 [Asn->Csd]: Inconsistant constant errors
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12726@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70421&edit=1 ID: 70421 Updated by: cmb@php.net Reported by: bensor987 at neuf dot fr Summary: Inconsistant constant errors -Status: Assigned +Status: Closed Type: Documentation Problem Package: Scripting Engine problem Operating System: Irrelevant PHP Version: 7.0.0RC1 Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2015-09-06 17:02:37] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=337760 Log: undefined qualified constants raise a fatal error (fixes #70421) ------------------------------------------------------------------------ [2015-09-03 17:36:34] cmb@php.net Using an undefined not namespaced constant is accepted for backward compatibility reasons, and it will be treated as string, additionally raising a notice, see <https://3v4l.org/J0R4j>. When namespaces were introduced, BC was no issue, so the more correct behavior of raising an error (an Error exception as of PHP 7, respectively) was adopted. So this is expected behavior, but it seems the documentation has to be improved. ------------------------------------------------------------------------ [2015-09-03 14:59:23] bensor987 at neuf dot fr "Error Exception", not "Fatal Error". The Fatal Error happens when I don't catch the Exception, sorry for that. ------------------------------------------------------------------------ [2015-09-03 14:55:39] bensor987 at neuf dot fr Description: ------------ A Fatal Error "Undefined constant" is triggered when I use a namespace on an undefined constant, but not when I don't. Test script: --------------- <?php try { echo \UNDEF_CONSTANT; } catch (Error $e) { echo "Fatal Error NS : " . $e->getMessage(); } try { echo UNDEF_CONSTANT; } catch (Error $e) { echo "Fatal Error w/o NS : " . $e->getMessage(); } Expected result: ---------------- One of these : - UNDEF_CONSTANTUNDEF_CONSTANT - Fatal Error NS : Undefined constant 'UNDEF_CONSTANT'Fatal Error w/o NS : Undefined constant 'UNDEF_CONSTANT' Actual result: -------------- Fatal Error NS : Undefined constant 'UNDEF_CONSTANT'UNDEF_CONSTANT ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70421&edit=1

« previous php.doc.bugs (#12726) next »