Req #49911 [Opn->Csd]: Allow using const keyword outside a class definition

From: Date: Sat, 21 Mar 2015 20:19:07 +0000
Subject: Req #49911 [Opn->Csd]: Allow using const keyword outside a class definition
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191509@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49911&edit=1 ID: 49911 Updated by: nikic@php.net Reported by: admin at d9tx dot com Summary: Allow using const keyword outside a class definition -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: * -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Supported since PHP 5.6. Previous Comments: ------------------------------------------------------------------------ [2009-10-18 08:24:41] admin at d9tx dot com Description: ------------ comparison const and define. define() allows expressions as the value. but const only allows scalar. Reproduce code: --------------- const FIRST_CONSTANT = __DIR__.DIRECTORY_SEPARATOR; // parse error define('SECOND_CONSTANT', __DIR__.DIRECTORY_SEPARATOR); // this work const THIRD_CONSTANT = SECOND_CONSTANT; // this work too Expected result: ---------------- const FIRST_CONSTANT = __DIR__.DIRECTORY_SEPARATOR; // expected same define() work define('SECOND_CONSTANT', __DIR__.DIRECTORY_SEPARATOR); // this work const THIRD_CONSTANT = SECOND_CONSTANT; // this work too ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49911&edit=1

« previous php.bugs (#191509) next »