note 69647 added to function.assert

From: Date: Wed, 13 Sep 2006 17:51:05 +0000
Subject: note 69647 added to function.assert
Groups: php.notes 
Request: Send a blank email to php-notes+get-117121@lists.php.net to get a copy of this message
Here is a simple demonstration of Design By Contract with PHP <?php assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_BAIL, 1); assert_options(ASSERT_CALLBACK, 'dcb_callback'); function dcb_callback($script, $line, $message) { echo "<h1>Condition failed!</h1><br /> Script: <strong>$script</strong><br /> Line: <strong>$line</strong><br /> Condition: <br /><pre>$message</pre>"; } // Parameters $a = 5; $b = 'Simple DCB with PHP'; // Pre-Condition assert(' is_integer($a) && ($a > 0) && ($a < 20) && is_string($b) && (strlen($b) > 5); '); // Function function combine($a, $b) { return "Kombined: " . $b . $a; } $result = combine($a, $b); // Post-Condition assert(' is_string($result) && (strlen($result) > 0); '); // All right, the Function works fine var_dump($result); ?> ---- Server IP: 66.163.161.117 Probable Submitter: 84.164.162.50 ---- Manual Page -- http://www.php.net/manual/en/function.assert.php Edit -- https://master.php.net/note/edit/69647 Del: integrated -- https://master.php.net/note/delete/69647/integrated Del: useless -- https://master.php.net/note/delete/69647/useless Del: bad code -- https://master.php.net/note/delete/69647/bad+code Del: spam -- https://master.php.net/note/delete/69647/spam Del: non-english -- https://master.php.net/note/delete/69647/non-english Del: in docs -- https://master.php.net/note/delete/69647/in+docs Del: other reasons-- https://master.php.net/note/delete/69647 Reject -- https://master.php.net/note/reject/69647 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117121) next »