(PHP 4, PHP 5, PHP 7)
assert_options — ����/��ȡ���Եĸ��ֱ�־
���� assert() �ĸ��ֿ���ѡ������ǽ�����ѯ��ǰ�����á�
what
��־ | INI ���� | Ĭ��ֵ | ���� |
---|---|---|---|
ASSERT_ACTIVE | assert.active | 1 | ���� assert() ���� |
ASSERT_WARNING | assert.warning | 1 | Ϊÿ��ʧ�ܵĶ��Բ���һ�� PHP ���棨warning�� |
ASSERT_BAIL | assert.bail | 0 | �ڶ���ʧ��ʱ��ִֹ�� |
ASSERT_QUIET_EVAL | assert.quiet_eval | 0 | �ڶ��Ա��ʽ��ֵʱ���� error_reporting |
ASSERT_CALLBACK | assert.callback | (NULL ) |
����ʧ��ʱ���ûص����� |
value
��־����ֵ��
���������־��ԭʼ���ã�����ʱ���� FALSE
��
Example #1 assert_options() ����
<?php
// �������ʧ��ʱ�ĺ���
function assert_failure()
{
echo 'Assert failed';
}
// ���ǵIJ��Ժ���
function test_assert($parameter)
{
assert(is_bool($parameter));
}
// ���ö��Ա�־
assert_options(ASSERT_ACTIVE, true);
assert_options(ASSERT_BAIL, true);
assert_options(ASSERT_WARNING, false);
assert_options(ASSERT_CALLBACK, 'assert_failure');
// ��һ�����Ի�ʧ��
test_assert(1);
// ���� ASSERT_BAIL �� true��������ԶҲ������
echo 'Never reached';
?>