Cannot use const within try block

From: Date: Fri, 16 May 2014 14:44:08 +0000
Subject: Cannot use const within try block
Groups: php.internals 
Request: Send a blank email to internals+get-74263@lists.php.net to get a copy of this message
The code below gives me: PHP Parse error: syntax error, unexpected T_CONST in ... try { const XXX = 12; echo "XXX = " . XXX . "\n"; }catch (ErrorException $e) { echo "error {$e->getMessage()}\n"; } It works if I put the 'cost' before/outside the 'try'. It also works if I replace the const line by: define('XXX', 'twelve'); or include "testdef.php"; where testdef.php contains: const XXX = 12; I cannot find this behaviour documented. a) If there is no good reason for this restriction - can it be removed. or b) If there is good reason for it can this be documented. Regards -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h>

« previous php.internals (#74263) next »