Doc #51340 [Opn->Csd]: const keyword inside code blocks causes parse error.

From: Date: Wed, 24 Mar 2010 15:33:33 +0000
Subject: Doc #51340 [Opn->Csd]: const keyword inside code blocks causes parse error.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4106@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51340&edit=1 ID: 51340 Updated by: degeberg@php.net Reported by: wrzasq at gmail dot com Summary: const keyword inside code blocks causes parse error. -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Debian GNU/Linux x86_64 PHP Version: 5.3.2 -Assigned To: +Assigned To: degeberg New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2010-03-24 16:33:10] degeberg@php.net Automatic comment from SVN on behalf of degeberg Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=296726 Log: Fixed PHP bug #51340 (const keyword inside code blocks causes parse error) ------------------------------------------------------------------------ [2010-03-21 11:21:43] johannes@php.net Constants defined using "const" are set during compile-time of the script whereas define() is done at runtime. By this const can't be used in conditional blocks, functions, ... This should be documented properly. ------------------------------------------------------------------------ [2010-03-21 04:15:39] wrzasq at gmail dot com Description: ------------ I tried to define constant using new const keyword structure in PHP 5.3. This one worked fine: -- $ cat test1.php <?php const FOO = 1; echo FOO; -- I checkd also this one: $ cat test2.php -- <?php if(true) { define('FOO', 1); } echo FOO; -- But this one crushes: -- $ cat test3.php <?php if(true) { const FOO = 1; } echo FOO; -- In fact im not using PHP 5.3.2, but PHP 5.3.1, but i don't have any place to test it against PHP 5.3.2 and I don't see fix for this issue on changelog fixes list. Expected result: ---------------- 1 1 1 Actual result: -------------- 1 1 Parse error: syntax error, unexpected T_CONST in /home/wrzasq/public_html/engine/chillout/projects/application/test3.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51340&edit=1

« previous php.doc.bugs (#4106) next »