PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

assert> <PHP volby a informace
Last updated: Sat, 24 Mar 2007

view this page in

assert_options

(PHP 4, PHP 5)

assert_options — Nastavit/získat různé příznaky výroků

Popis

mixed assert_options ( int $what [, mixed $value] )

S použitím funkce assert_options() můžete nastavit různé řídící volby funkce assert(), nebo jen získat jejich současné nastavení.

Tabulka 236. Volby výroků

volbaini parametrvýchozí hodnotapopis
ASSERT_ACTIVEassert.active1zapne assert() vyhodnocování
ASSERT_WARNINGassert.warning1vytvoří PHP varování pro každý selhavší výrok
ASSERT_BAILassert.bail0ukončí provádění skiptu, pokud výrok selže
ASSERT_QUIET_EVALassert.quiet_eval0 vypne error_reporting během vyhodnocování výrazů výroků
ASSERT_CALLBACKassert_callback(NULL)uživatelská funkce, která se zavolá pro každý selhavší výrok

assert_options() vrací původní nastavení volby, nebo FALSE při chybě.



add a note add a note User Contributed Notes
assert_options
Frdric Bouchery
20-Jul-2003 04:25
Here is an exemple how to use the assertion callback function :

<?php
  assert_options
( ASSERT_CALLBACK, 'assert_callback');

  function
assert_callback( $script, $line, $message ) {
    echo
'You have a design error in your script <b>', $script,'</b> : line <b>', $line,'</b> :<br />';
    echo
'<b>', ereg_replace( '^.*//\*', '', $message ), '</b><br /><br />';
    echo
'Open the source file and check it, because it\'s not a normal behaviour !';
    exit;
  }

 
$x = 3;
 
assert('is_integer( $x ) && ($x >= 0) && ($x <= 10); //* $x must be an integer value from 0 to 10' );
  echo
"0 <= $x <= 10";
?>

assertion is usefull for "design by contract" methodology ...

assert> <PHP volby a informace
Last updated: Sat, 24 Mar 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites