Using the assert() Function : Assertion « Language Basics « PHP






Using the assert() Function

 
<?php

    function add_odd_numbers($x, $y) {
        assert('!(($x % 2) && ($y % 2))');
        return ($x + $y);
    }

    $answer_one = add_odd_numbers(3, 5);
    $answer_two = add_odd_numbers(2, 4);

    echo "3 + 5 = $answer_one\n";
    echo "2 + 4 = $answer_two\n";

?>
  
  








Related examples in the same category

1.Assertion Options