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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: klawd+phpbugs at kamundo dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 19:01:36 2025 UTC