Req #45963 [Fbk->NoF]: Undefined variable should cause an error

From: Date: Sun, 24 Jan 2016 04:22:38 +0000
Subject: Req #45963 [Fbk->NoF]: Undefined variable should cause an error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198849@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=45963&edit=1 ID: 45963 Updated by: php-bugs@lists.php.net Reported by: andyincolorado at gmx dot net Summary: Undefined variable should cause an error -Status: Feedback +Status: No Feedback Type: Feature/Change Request Package: *General Issues Operating System: Any PHP Version: 6CVS-2008-09-01 (CVS) Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2016-01-15 14:38:21] danack@php.net "This could either be done by using an option" If you set an error handler that throws an exception for all warnings, you will have the behaviour that you want. ------------------------------------------------------------------------ [2008-09-01 12:04:50] andyincolorado at gmx dot net Description: ------------ In all PHP version I've tested so far, using an undefined variable (see code below) will cause a notice to be thrown. However, it would be better to throw an error, since using an undefined variable can cause unpredictable results or (as in my case) data loss. Same would go to the "undefined index" notice for arrays. This could either be done by using an option, allowing users to turn it off or without an option, since PHP6 changes so many things that developers will have to adapt their scripts. Reproduce code: --------------- // Note that $bar isn't defined anywhere in the script $foo = $bar + 5; Expected result: ---------------- An error message that causes the script to cease running. Actual result: -------------- A notice ("Undefined variable $foo...") is thrown. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=45963&edit=1

« previous php.bugs (#198849) next »