php.net |  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:
MUST BE VALID
Solve the problem:
49 - 6 = ?
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);".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC