, "typecheck.php" :
assert_string($s) {
assert( is_string($), 'not a string');
}
assert_int($i) {
assert( is_int($i), 'not an integer);
}
... lots more type checks as appropriate ...
"" "typecheck.php" - :
require("typecheck.php");
...
function foo($s) {
assert_string($s);
...
.
, , , ; , , , .
; :
assert_integer_range($i, $l, $u) {
assert_int($i);
assert($i>=$l);
assert($i<=$u);
}
bar($n) {
assert_integer_range($n,1,10);
...
, , , , .
assert_xxx , , . "typecheck.php" , , . , .
- , .