Home » » assert

assert

Written By 1 on Sunday, September 30, 2012 | 7:13 PM

bool assert ( mixed $assertion [, string $description ] )

Checks if assertion is FALSE

assert() will check the given assertion and take appropriate action if its result is FALSE.


<?php
// Active assert and make it quiet
assert_options(ASSERT_ACTIVE1);
assert_options(ASSERT_WARNING0);
assert_options(ASSERT_QUIET_EVAL1);

// Create a handler function
function my_assert_handler($file$line$code)
{
    echo 
"<hr>Assertion Failed:
        File '
$file'<br />
        Line '
$line'<br />
        Code '
$code'<br /><hr />";
}

// Set up the callback
assert_options(ASSERT_CALLBACK'my_assert_handler');

// Make an assertion that should fail
assert('mysql_query("")');
?>

5.4.8 The description parameter was added. The description is also now provided to a callback function in ASSERT_CALLBACK mode as the fourth argument.


Future will be better than thy past (ElectroFest Summer'12, UITS, Dhaka)

0 Comment:

Post a Comment