4 ms·
> Undefined variable: Error exception instead of notice Well, this is where the chaff separates from the wheat. There's no small amount of crappy code out ther
by chx 7y ago
> Undefined variable: Error exception instead of notice
Well, this is where the chaff separates from the wheat. There's no small amount of crappy code out there which will WSOD after this. Or actually print the exception because they couldn't even bother to switch display errors on... Of course, no even remotely sane codebase will be affected, but... Make no mistake, this is a good change but it will cause some teeth gnashing.
- codetrotter 7y agoOver time I think (hope) this sort of change will help to improve the code that people write. But I will not be surprised to see some people say things like “PHP 8 broke my code”. Of course, what those people might not realize is that PHP 8 did not break their code, the code was always broken, and PHP 8 is now going to surface the brokenness of that code. But even with code that people refuse to fix, this sort of change will make the brokenness of that code more apparent to others, and so the number of people that use that broken code will cease to grow. If not entirely, then at least reduce in pace of growth. That is good for the ecosystem of computing. As a proponent of correctness in computing, this makes me happy :) We all write bugs, but everything our tools and languages of choice can do to help us reduce the number of bugs and the severity (impact on security) of our bugs, the better.
- userbinator 7y agoI think it's really a philosophical question what is "broken". An undefined variable used to have a particular and also well-defined behaviour, now it has a different behaviour. Personally, I think a lot of these design decisions which some people abhor is why PHP became popular in the first place. In that perspective, turning it into yet another "big bureaucratic language" is very much against the spirit of its existence.
- koolba 7y agoSince the dawn of programming there’s been a schism as to whether undefined means empty versus being a logical error. But deep down we all know what it should mean.
- tim-- 7y agoPHP has always warned about this since version 5.6 - if not earlier. To stop the warnings, configuration would need to be changed in PHP config, or those warnings be silenced by the developer. Any decent webapp has had this issues resolved a long time ago. I would suggest that websites that will be effected probably will not migrate to PHP 8 that quickly.
- thdrdt 7y agoTrue. I always turned it on while developing. This saved me from a lot of buggy code. But there are a million questions on the internet about this 'error'. And the answer is almost always: turn the errors off. And I believe this is the biggest problem with PHP. A lot of inexperienced users with questions that get very bad answers.
- mpol 7y ago"Turn display_errors off" is a good answer for a production website. You will get problems with headers and cookies, if notices are printed before headers are sent. You might also divulge information about your stack to users. For a development and staging website you do want notices and warnings displayed. For a production website possibly only when testing something.
- jbboehr 7y ago> For a development and staging website you do want notices and warnings displayed. Just SSH in and tail the log. Dealing with unexpected output from errors clobbering your headers isn't worth the trouble. You can also try something like FirePHP [0] if you need the errors in the context of the current page. [0]: http://www.firephp.org/ http://www.firephp.org/
- webkike 7y agoIf you only get this error after installing Sys packages, it is time to upgrade
- muglug 7y agoThe article is incorrect - the vote for that was defeated: https://wiki.php.net/rfc/engine_warnings#vote https://wiki.php.net/rfc/engine_warnings#vote Undefined variables will now be warnings (and one might expect PHP 9 to reclassify them as exceptions).
- blowski 7y agoIn my experience, the kind of crappy codebase this would affect would never be upgraded anyway. Many of them are still on PHP 4!