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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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: Sun Jun 16 08:01:29 2024 UTC