PHP Classes

File: throw_exception.php

Recommend this page to a friend!
  Classes of Allan Kibet  >  Learn New PHP 8 Features  >  throw_exception.php  >  Download  
File: throw_exception.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Learn New PHP 8 Features
Examples of how to use PHP 8 new features
Author: By
Last change:
Date: 8 months ago
Size: 231 bytes


Class file image Download

function divide(int $a, int $b): float {
    if (
$b == 0) {
// You can throw an exception within any expression
throw new Exception("Can't divide by 0");
$a / $b;


For more information send a message to info at phpclasses dot org.