php 5.3.2 not throwing exceptions

Posted by tipu on Stack Overflow See other posts from Stack Overflow or by tipu
Published on 2010-04-08T10:25:21Z Indexed on 2010/04/08 10:33 UTC
Read the original article Hit count: 352

Filed under:
|
|

I'm attempting to throw an exception using php 5.3.2 and it is giving me the following error:

Parse error: syntax error, unexpected T_THROW

I am attempting to throw an exception the following way:

throw new Exception('Property ' . $name . ' doesn\'t exist in class Index', '');

Edit: I also tried

throw new Exception('Property ' . $name . ' doesn\'t exist in class Index');

it didn't change the error I was getting.

The complete method:

public function __get($name) 
    {
        if(property_exists($this, $name)
            throw new Exception('Property ' . $name . ' doesn\'t exist in class Index');
        return $this->$name;
    }

© Stack Overflow or respective owner

Related posts about php5.3

Related posts about php