php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52823 getting constants off variables works, not fields
Submitted: 2010-09-13 04:08 UTC Modified: 2010-09-13 04:35 UTC
From: klawd+phpbugs at kamundo dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.3 OS: ubuntu
Private report: No CVE-ID: None
 [2010-09-13 04:08 UTC] klawd+phpbugs at kamundo dot de
Description:
------------
<?php
// this works:
$class = new MyClass();
echo $class::constant."\n"; // As of PHP 5.3.0

// this doesn't but should:
class Foo
{
  public function __construct()
  {
    $this->bar=new MyClass();
    echo $this->bar::constant;
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-13 04:35 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2010-09-13 04:35 UTC] cataphract@php.net
Constants are like static fields, you're supposed to access them statically.

Even if you were to disagree, this is by design; it's not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 14:01:36 2024 UTC