note 34269 added to function.assert-options
| From: | "Fr�d�ric" at rack1 dot php dot net | Date: | Sun, 20 Jul 2003 21:25:41 +0000 |
| Subject: | note 34269 added to function.assert-options | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52423@lists.php.net to get a copy of this message | ||
Here is an exemple how to use the assertion callback function :
<?php
assert_options( ASSERT_CALLBACK, 'assert_callback');
function assert_callback( $script, $line, $message ) {
echo 'You have a design error in your script <b>', $script,'</b> :
line <b>', $line,'</b> :<br />';
echo '<b>', ereg_replace( '^.*//\*', '', $message ),
'</b><br /><br />';
echo 'Open the source file and check it, because it\'s not a normal behaviour !';
exit;
}
$x = 3;
assert('is_integer( $x ) && ($x >= 0) && ($x <= 10); //* $x must be an
integer value from 0 to 10' );
echo "0 <= $x <= 10";
?>
assertion is usefull for "design by contract" methodology ...
----
Manual Page -- http://www.php.net/manual/en/function.assert-options.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34269
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34269&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34269&report=yes