|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-22 17:03 UTC] nikic@php.net
[2021-08-19 12:50 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2021-08-19 12:50 UTC] cmb@php.net
[2021-08-29 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ I want to get assertion code "assert(sleep(3))", but return "Assertion failed" or $exception->getMessage() === "". =========================================================== php -r 'assert_options(ASSERT_ACTIVE,true);assert(sleep(3));' PHP Warning: assert(): **assert(sleep(3))** failed in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. assert() Command line code:1 Warning: assert(): **assert(sleep(3))** failed in Command line code on line 1 Call Stack: 0.0001 406984 1. {main}() Command line code:0 3.0001 407360 2. assert() Command line code:1 =========================================================== script file "test.php": <?php echo PHP_SAPI,PHP_EOL; assert_options(ASSERT_ACTIVE,true); assert(sleep(3)); ?> =========================================================== lynx localhost/test.php fpm-fcgi ( ! ) Warning: assert(): **Assertion failed** in /path/to/test.php on line 4 Call Stack # Time Memory Function Location 1 0.0002 406992 {main}( ) .../exception.php:0 2 3.0003 407368 assert ( ) .../exception.php:4 =========================================================== php test.php cli PHP Warning: assert(): **Assertion failed** in /path/to/test.php on line 4 PHP Stack trace: PHP 1. {main}() /path/to/test.php:0 PHP 2. assert() /path/to/test.php:4 Warning: assert(): Assertion failed in /path/to/test.php on line 4 Call Stack: 0.0001 407896 1. {main}() /path/to/test.php:0 3.0002 408304 2. assert() /path/to/test.php:4 =========================================================== php -r 'assert_options(ASSERT_ACTIVE,true);assert_options(ASSERT_EXCEPTION,true);assert(sleep(3));' PHP Fatal error: Uncaught AssertionError: **assert(sleep(3))** in Command line code:1 Stack trace: #0 Command line code(1): assert(0, 'assert(sleep(3)...') #1 {main} thrown in Command line code on line 1 Fatal error: Uncaught AssertionError: **assert(sleep(3))** in Command line code on line 1 AssertionError: assert(sleep(3)) in Command line code on line 1 Call Stack: 0.0000 407384 1. {main}() Command line code:0 3.0001 407760 2. assert() Command line code:1 =========================================================== script file "test_with_exception.php": <?php echo PHP_SAPI,PHP_EOL; assert_options(ASSERT_ACTIVE,true); assert_options(ASSERT_EXCEPTION,true); assert(sleep(3)); ?> =========================================================== lynx localhost/test_with_exception.php fpm-fcgi ( ! ) Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php on line 5 ( ! ) AssertionError: in /path/to/test_with_exception.php on line 5 Call Stack # Time Memory Function Location 1 0.0001 407496 {main}( ) .../test_with_exception.php:0 2 3.0002 407872 assert ( ) .../test_with_exception.php:5 =========================================================== php test_with_exception.php cli PHP Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php:5 Stack trace: #0 /path/to/test_with_exception.php(5): assert(0) #1 {main} thrown in /path/to/test_with_exception.php on line 5 Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php on line 5 AssertionError: in /path/to/test_with_exception.php on line 5 Call Stack: 0.0001 408408 1. {main}() /var/www/vhost/e/exception.php:0 3.0002 408816 2. assert() /var/www/vhost/e/exception.php:5