|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #20075 assert() callback doesn't get expression
Submitted: 2002-10-24 17:05 UTC Modified: 2002-10-25 00:47 UTC
From: leon at leonatkinson dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0-pre1 OS: RH 7.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: leon at leonatkinson dot com
New email:
PHP Version: OS:


 [2002-10-24 17:05 UTC] leon at leonatkinson dot com
It looks like the callback function registered with assert_options() only gets the third argument set when assert() is called with a string.  Consider the following script.

	function failedAssertion($file, $line, $expression)
		print("'$file', '$line', '$expression'<br>");

	assert_options(ASSERT_ACTIVE, TRUE);
	assert_options(ASSERT_CALLBACK, "failedAssertion");
	assert("1 == 2");
	assert(1 == 2);

This produces the following.

'/usr/local/apache/htdocs/tricks/assert.php', '9', '1 == 2'
'/usr/local/apache/htdocs/tricks/assert.php', '10', ''

If I turn error reporting on, the warning messages mirror this by leaving out the expression.

Looks like the assert.phpt doesn't test assert() for the old form.  Maybe it needs a line like "assert($a != 0);".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-25 00:30 UTC]
This is not a bug. Docs need a bit of a clarification about this though. Assigned to Derick per his request.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 23 08:03:33 2021 UTC