assert_options
Description
The assert_options of Options / Information for PHP set/get the various assert flags.
Syntax
assert_options(int $what, mixed $value = ?): mixed
Parameters
what
Option | INI Setting | Default value | Description |
---|---|---|---|
ASSERT_ACTIVE | assert.active | 1 | enable assert() evaluation |
ASSERT_WARNING | assert.warning | 1 | issue a PHP warning for each failed assertion |
ASSERT_BAIL | assert.bail | 0 | terminate execution on failed assertions |
ASSERT_CALLBACK | assert.callback | (null) | Callback to call on failed assertions |
value
An optional new value for the option.
The callback function set via ASSERT_CALLBACK or assert.callback should have the following signature:
assert_callback ( string $file, int $line, string $assertion, string $description = ? ): void
file
The file where assert() has been called.
line
The line where assert() has been called.
assertion
The assertion that has been passed to assert(), converted to a string.
description
The description that has been passed to assert().
Return
Returns the original setting of any option or false on errors.
Examples
1 · ASSERT_ACTIVE
<? $what = ASSERT_ACTIVE; $value = 1; $return = assert_options($what, $value); assert(true == false); var_export($return);
1
2 · ASSERT_WARNING
<? $what = ASSERT_WARNING; $value = 1; $return = assert_options($what, $value); assert(true == false); var_export($return);
1
3 · ASSERT_BAIL
<? $what = ASSERT_BAIL; $value = 0; $return = assert_options($what, $value); assert(true == false); var_export($return);
0
4 · ASSERT_CALLBACK
<? function assert_callback($file, $line, $assertion, $description) { echo "file: $file\nline: $line\nassertion: $assertion\ndescription: $description"; } $what = ASSERT_CALLBACK; $value = 'assert_callback'; $return = assert_options($what, $value); assert(true == false); var_export($return);
NULL
Links
Options / Information
- assert
- cli_get_process_title
- cli_set_process_title
- dl
- extension_loaded
- gc_collect_cycles
- gc_disable
- gc_enable
- gc_enabled
- gc_mem_caches
- gc_status
- get_cfg_var
- get_current_user
- get_defined_constants
- get_extension_funcs
- get_include_path
- get_included_files
- get_loaded_extensions
- get_required_files
- get_resources
- getenv
- getlastmod
- getmygid
- getmyinode
- getmypid
- getmyuid
- getopt
- getrusage
- ini_alter
- ini_get
- ini_get_all
- ini_parse_quantity
- ini_restore
- ini_set
- memory_get_peak_usage
- memory_get_usage
- memory_reset_peak_usage
- php_ini_loaded_file
- php_ini_scanned_files
- php_sapi_name
- php_uname
- phpcredits
- phpinfo
- phpversion
- putenv
- set_include_path
- set_time_limit
- sys_get_temp_dir
- version_compare
- zend_thread_id
- zend_version