php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36952 Can't set an error handler to the private method
Submitted: 2006-04-02 18:21 UTC Modified: 2006-04-02 19:11 UTC
From: acc dot data at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5CVS-2006-04-02 (snap) OS: Windows 2003
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: acc dot data at gmail dot com
New email:
PHP Version: OS:

 

 [2006-04-02 18:21 UTC] acc dot data at gmail dot com
Description:
------------
Can't set an error handler to a private method from another (public) method of the same class

Reproduce code:
---------------
<?php

class Test
{
	private function errorHandler($errno, $errstr, $errfile, $errline)
	{
		echo "handled";
	}
	function __construct()
	{
		set_error_handler(array(&$this, "errorHandler"));
		$dom = new DOMDocument();
		$dom->load("not found"); // warning
		restore_error_handler();
	}
}

$test = new Test();

?>

Expected result:
----------------
handled

Actual result:
--------------
Fatal error: Call to private method Test::errorHandler() from context '' in C:\test.php on line 13

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-02 18:35 UTC] mike@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The error handler is called from outside of this class, so it must be public.

 [2006-04-02 19:11 UTC] acc dot data at gmail dot com
Thank you
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC