php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49828 class-constant can't be set to negative infinity
Submitted: 2009-10-10 00:44 UTC Modified: 2009-10-19 16:10 UTC
From: daniel dot meister at datahouse dot ch Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.11 OS: Ubuntu 09.04
Private report: No CVE-ID: None
 [2009-10-10 00:44 UTC] daniel dot meister at datahouse dot ch
Description:
------------
It is not possible to set a class-constant to the value of negative infinity (-INF) while it is possible to set it to any float value or even to positive infinity (INF) or not-a-number (NAN).

configuration:
- no configure options
- no changes to php.ini

Reproduce code:
---------------
class A {

    const a = -INF;

}

echo is_infinite(A::a);


Expected result:
----------------
1

Actual result:
--------------
Fatal error: Unsupported operand types in /path/to/file/filename.php on line n


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-10 11:46 UTC] daniel dot meister at datahouse dot ch
possible workarounds:

define("C",-INF);
class A {
    const a = C;
}

class A {
    const a = -1E100000000;
}
 [2009-10-10 12:08 UTC] Sjoerd@php.net
Could reproduce with PHP 5.2-HEAD and PHP 5.3-HEAD. The error occurs on the line with:
    const a = -INF;

Note that the same error occurs with:
    const a = -(1);

Because you can't use an expression when defining a constant.
 [2009-10-19 15:06 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2009-10-19 16:10 UTC] jani@php.net
-INF is same as -1 * INF and that's an expression.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 31 18:00:03 2025 UTC