#51010 [Opn]: Bad example
| From: | chris dot dickinson at web dot de | Date: | Thu, 11 Feb 2010 09:14:25 +0000 |
| Subject: | #51010 [Opn]: Bad example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3865@lists.php.net to get a copy of this message | ||
ID: 51010
User updated by: chris dot dickinson at web dot de
Reported By: chris dot dickinson at web dot de
Status: Open
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
Maybe the author wanted to write something like the following? :
<?php
if ($divisor == 0) {
trigger_error("Cannot divide by zero", E_USER_ERROR);
}
?>
or
<?php
if ( ! assert($divisor != 0)) {
trigger_error("Cannot divide by zero", E_USER_ERROR);
}
?>
Previous Comments:
------------------------------------------------------------------------
[2010-02-11 08:31:34] chris dot dickinson at web dot de
Description:
------------
Hi,
On your page http://ch2.php.net/manual/en/function.trigger-error.php
you give only this example
<?php
if (assert($divisor == 0)) {
trigger_error("Cannot divide by zero", E_USER_ERROR);
}
?>
It seems badly chosen. If $divisor is 0 then the assertion succeeds,
when actually you would probably not want $divisor to be 0 (!). If
$divisor is anything else but 0, the assertion will fail and give you an
error message. I got: "Warning: assert() [function.assert]: Assertion
failed in ..."
Reproduce code:
---------------
---
From manual page: function.trigger-error#Examples
---
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=51010&edit=1