17/05/2012 4:46am

PHP | Problem - I suck at error handling


        //Popover Shortcode Function

public function Popover($arguments, $text = null) {

//Stop SilverStripe breaking with a [Notice] Undefined index: id error.
//This isn't working

try {
$PopoverID = $arguments['id'];
} catch (Exception $e) {
return null;
}

...
//Proceed as normal
...

}


1 Comments 1 Solutions

17/05/2012 5:03am

PHP | Solution - Sticks

Fixed

//Instead of try/catch use the below if statement.

if (!isset($arguments['id'])) {
return null;
}


Post Comment