note 123522 added to function.assert
| From: | keikland@php.net | Date: | Wed, 16 Jan 2019 19:01:29 +0000 |
| Subject: | note 123522 added to function.assert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210066@lists.php.net to get a copy of this message | ||
Had a tricky situation where the code with assert() worked fine in development, but not in
production. The problem was when variables changed value as part of the assert test, for example:
assert(5 === ++$i);
This is valid PHP code, but caused havoc in production when the logic expected $i to have been
incremented. A similar problem would exist with in-line assignments, such as:
assert(!$i = sin($angle));
This is probably a very rare problem, but PHP should in principle throw an error in such cases.
Hopefully that can be added in all maintained versions.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.142 (proxied: 85.166.29.87)
----
Manual Page -- http://php.net/manual/en/function.assert.php
Edit -- https://master.php.net/note/edit/123522
Del: integrated -- https://master.php.net/note/delete/123522/integrated
Del: useless -- https://master.php.net/note/delete/123522/useless
Del: bad code -- https://master.php.net/note/delete/123522/bad+code
Del: spam -- https://master.php.net/note/delete/123522/spam
Del: non-english -- https://master.php.net/note/delete/123522/non-english
Del: in docs -- https://master.php.net/note/delete/123522/in+docs
Del: other reasons-- https://master.php.net/note/delete/123522
Reject -- https://master.php.net/note/reject/123522
Search -- https://master.php.net/manage/user-notes.php