|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
41 - 14 = ?
Subscribe to this entry?

 [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: Tue Oct 19 14:03:33 2021 UTC