php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68177 declare() + named constant = "Cannot convert to ordinal value"
Submitted: 2014-10-07 13:17 UTC Modified: 2014-10-23 19:53 UTC
From: mikko dot rantalainen at peda dot net Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.6.1 OS: Ubuntu Linux 10.04 LTS
Private report: No CVE-ID: None
 [2014-10-07 13:17 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-17 11:39 UTC] tyrael@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2014-10-17 11:39 UTC] tyrael@php.net
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.
 [2014-10-23 19:53 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=335128
Log: Clarify what types of values can be given to declare directives.

Fixes doc bug #68177 (declare() + named constant = &quot;Cannot convert to ordinal
value&quot;).
 [2014-10-23 19:53 UTC] aharvey@php.net
-Package: Compile Warning +Package: Documentation problem
 [2014-10-23 19:53 UTC] aharvey@php.net
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.
 [2014-10-23 19:53 UTC] aharvey@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: aharvey
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 10:00:01 2026 UTC