php8.5
Home/ Manual/ predefined / exception/ Exception::__clone

Exception::__clone

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Clone the exception

Description

Exception::__clone(): void

Exceptions do not support cloning; this method exists only to prevent it.

Warning

Exceptions cannot be cloned, whether they are instances of Exception or of a subclass. Attempting to clone an exception throws an Error, which may be caught.

Parameters Parameters

Return Values

Void

Errors/Exceptions

Exceptions are not clonable.

Changelog

VersionDescription
8.1.0Exception::__clone is no longer declared final, because declaring a private method final emits a warning as of PHP 8.0.0. Exceptions remain uncloneable.

Source: language/predefined/exception/clone.xml · from the official PHP manual (php/doc-en)