note 98521 added to function.assert
| From: | uramihsayibok at osu1 dot php dot net | Date: | Sun, 20 Jun 2010 20:48:22 +0000 |
| Subject: | note 98521 added to function.assert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170334@lists.php.net to get a copy of this message | ||
There's a nice advantage to giving assert() some code to execute, as a string, rather than a
simple true/false value: commenting.
<?php
assert('is_int($int) /* $int parameter must be an int, not just numeric */');
// and my personal favorite
assert('false /* not yet implemented */');
?>
The comment will show up in the output (or in your assertion handler) and doesn't require
someone debugging to go through your code trying to figure out why the assertion happened.
That's no excuse to not comment your code, of course.
You need to use a block comment (/*...*/) because a line comment (//...) creates an "unexpected
$end" parse error in the evaluated code. Bug? Could be.
(You can get around it with "false // not yet implemented\n" but that screws up the
message)
----
Server IP: 209.68.5.5
Probable Submitter: 75.172.105.70
----
Manual Page -- http://www.php.net/manual/en/function.assert.php
Edit -- https://master.php.net/note/edit/98521
Del: integrated -- https://master.php.net/note/delete/98521/integrated
Del: useless -- https://master.php.net/note/delete/98521/useless
Del: bad code -- https://master.php.net/note/delete/98521/bad+code
Del: spam -- https://master.php.net/note/delete/98521/spam
Del: non-english -- https://master.php.net/note/delete/98521/non-english
Del: in docs -- https://master.php.net/note/delete/98521/in+docs
Del: other reasons-- https://master.php.net/note/delete/98521
Reject -- https://master.php.net/note/reject/98521
Search -- https://master.php.net/manage/user-notes.php