<?php

class Foo
{
    function doSomething()
    {
        $lastException = null;

        foreach (range(0, 10) as $i) {
            try {
                throw new Exception($i);
            } catch (Exception $e) {
                $lastException = $e;
            }
        }

        throw $e;
    }
}

$f = new Foo;
try {
    $f->doSomething();
} catch (Exception $e) {
    print($e->getMessage());
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: