php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36490 Constructor method name for the inherited Exception class
Submitted: 2006-02-22 21:52 UTC Modified: 2006-02-22 23:04 UTC
From: tech at vosys dot com dot br Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.2 OS: Linux / Windows
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tech at vosys dot com dot br
New email:
PHP Version: OS:

 

 [2006-02-22 21:52 UTC] tech at vosys dot com dot br
Description:
------------
I used the constructor method name like __constructor for an Exception class. When I tried get a attribute value from a catch{} block this is not returned.

When I set the constructor method name like the class name works well.

Reproduce code:
---------------
class Except extends Exception{// SIMPLE CLASS FOR ERROR MANAGEMENT
	private $e = '';
	public function __construcor($msg){	$this->e = $msg; }
	public function getErrorMessage(){	return $this->e; }
}
class Test{// CLASS FOR SIMPLE TEST
	public function Test($info){
		try{
			if ($info != 'ok'){
				throw new Except('Error Simulation');
			}else{
				throw new Except('Positive Simulation');
			}
		}catch(Exception $e){
			throw $e;
		}
	}
}
try{// ERROR SIMULATION
	$objXtpo = new Test('hi');
}catch(Exception $e){
	echo('Exception is: '. $e->getErrorMessage());
}

Expected result:
----------------
Exception is: Error Simulation

Actual result:
--------------
Exception is:

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-22 21:57 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The name should be __construct, not __constructor...
 [2006-02-22 23:04 UTC] tech at vosys dot com dot br
Sorry, really so sorry.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu May 07 21:00:02 2026 UTC