Edit report at https://bugs.php.net/bug.php?id=68177&edit=1
ID: 68177
Updated by: tyrael@php.net
Reported by: mikko dot rantalainen at peda dot net
Summary: declare() + named constant = "Cannot convert to
ordinal value"
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
Package: Compile Warning
Operating System: Ubuntu Linux 10.04 LTS
PHP Version: 5.6.1
Block user comment: N
Private report: N
New Comment:
declare is a compile time construct, and you can't use variables, constants or expressions with
it, because they aren't resolved yet.
so this shortcoming is expected and http://www.php.net/declare should be updated to explain this.
Previous Comments:
------------------------------------------------------------------------
[2014-10-07 13:17:27] mikko dot rantalainen at peda dot net
Description:
------------
The declare construct raises a warning "Cannot convert to ordinal value" if a named
constant is used as a parameter. If this is intentional limitation, it should be documented.
Otherwise, this is a bug.
Test case at http://3v4l.org/YFZ4D
Test script:
---------------
<?php
define("CONFIG_TICKS", 1);
declare(ticks=CONFIG_TICKS);
$x = "test";
Expected result:
----------------
The declared value of 'ticks' should be 1 and the script should emit no output.
Actual result:
--------------
Warning: Cannot convert to ordinal value in /in/YFZ4D on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68177&edit=1