php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42328 it's impossible to reference the class using a variable
Submitted: 2007-08-17 13:24 UTC Modified: 2007-08-17 13:25 UTC
From: taquito at o2 dot pl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.4RC2 OS: mandriva cooker
Private report: No CVE-ID: None
 [2007-08-17 13:24 UTC] taquito at o2 dot pl
Description:
------------
documentation for Scope Resolution Operator (::) states "As of PHP 5.2.4, it's possible to reference the class using a variable", which is not true.
example 19.12 is wrong

Reproduce code:
---------------
<?php

class MyClass {
    const CONST_VALUE = 'A constant value';
}

$classname = 'MyClass';
echo $classname::CONST_VALUE;

echo MyClass::CONST_VALUE;

?>

Expected result:
----------------
A constant valueA constant value

Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in /home/alhambra/www/tst/test.php on line 8

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 13:25 UTC] jani@php.net
And that comment is already removed from the documentation and documentation is being regenerated right this moment..this feature will be in PHP 5.3..
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 23:01:28 2024 UTC