I'm using this code inside the public function __construct()
of a class
:
$this->mConnection = mysql_connect(BASE_DB_HOST,BASE_DB_USER,BASE_DB_PASS) or throw new Exception("Couldn't connect to database.");
BASE_DB_HOST
, BASE_DB_USER
and BASE_DB_PASS
are defined. I get the following error:
Parse error: syntax error, unexpected T_THROW in /home/... on line 6
Am I not allowed to use the or
construction with Exceptions? How can I workaround this?
$connection = mysql_connect(BASE_DB_HOST,BASE_DB_USER,BASE_DB_PASS) or die("Couldn't connect to database.")
; – Mahaffeythrow
is a statement,or
needs to be followed by an expression. – Cadgethrow
,return
) mixed with expressions. – Alurta