Can only throw objects¶
Description¶
The throw
keyword operates on exceptions, which are exclusively objects.
Example¶
<?php
throw 1;
?>
Solutions¶
Use
throw new Exception()
.Use
throw new Error()
.Use
throw $object
, where $object contains an error or an exception.Use
throw ($object)
, where $object contains an error or an exception.