php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80479 Exception code is defaulted (apparently) to integer zero, but not documented
Submitted: 2020-12-03 13:27 UTC Modified: 2020-12-03 14:09 UTC
From: scott at scott-corcoran dot com Assigned: cmb (profile)
Status: Not a bug Package: Documentation problem
PHP Version: 7.3.25 OS: Debian
Private report: No CVE-ID: None
 [2020-12-03 13:27 UTC] scott at scott-corcoran dot com
Description:
------------
<?php

	try
	{
		throw new Exception('xxxx');
	}
	catch(Exception $x)
	{
		echo serialize($x->getCode());
	}
?>
i:0;
Documentation, 
class Exception:
 Methods

       o public Exception::__construct NULL ([string  $message = ""], [int  $code], [Exception  $previous])



Test script:
---------------
As in the description:
	try
	{
		throw new Exception('xxxx');
	}
	catch(Exception $x)
	{
		if (serialize($x->getCode() == 's:0;')
                        exit(0);
                throw new Exception('Invalid exception code default');
	}

Expected result:
----------------
silence


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-03 13:43 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-12-03 13:43 UTC] cmb@php.net
This appears to be properly documented: <https://www.php.net/manual/en/exception.construct.php>.

Is this perhaps about an out-dated translation?  Which one?
 [2020-12-03 14:04 UTC] scott at scott-corcoran dot com
Never mind. Close it. It must have been fixed between the php7
 docs I downloaded maybe before 7.3.19 and now.
 [2020-12-03 14:09 UTC] cmb@php.net
-Status: Feedback +Status: Not a bug
 [2020-12-03 14:09 UTC] cmb@php.net
Thanks for the swift reply! :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC