★ wanayoo — archive 1999 http://www.php.net/manual/kr/function.assert.phpNouvelle recherche | Portail wanayoo
PHP Tuesday, April 17, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  


previousPHP options/info
assert_optionsnext

Last updated: Mon, 09 Apr 2001
view this page in English | Brazilian Portuguese | Czech | Dutch | French | Italian | Japanese | Korean | Plain HTML

assert

(PHP 4 >= 4.0b4)

assert -- Checks if assertion is false

Description

int assert (string|bool assertion)

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

If the assertion is given as a string it will be evaluated as PHP code by assert(). The advantages of a string assertion are less overhead when assertion checking is off and messages containing the assertion expression when an assertion failes.

Assertion should be used as a debugging feature only. You may use them for sanity-checks that test for conditions that should always be true and that indicate some programming errors if not or to check for the presence of certain features like extension functions or certain system limits and features.

Assertions should not be used for normal runtime operations like input parameter checks. As a rule of thumb your code should always be able to work correct if assertion checking is not activated.

The behavior of assert() may be configured by assert_options() or by .ini-settings described in that functions manual page.

User Contributed Notes: assert
aulbach@unter.franken.de^
13-Mar-2001 06:56
Example:

<?php

$boolassert=false;
assert($boolassert);

$stringassert="\$blafasel==1";
$blafasel="jiji";
assert($stringassert);

?>

-> returns

Warning: Assertion failed in /.../assert.php on line 4

Warning: Assertion "$blafasel==1" failed in /.../assert.php on line 8

previousPHP options/info
assert_optionsnext

Last updated: Mon, 09 Apr 2001
add note | about notes

show source | credits | stats | mirror sites:  

Copyright © 2001 The PHP Group
All rights reserved.
This mirror generously provided by: chek.com
Last updated: Tue Apr 17 07:45:01 2001 EDT