|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77851 __CLASS__ empty inside function inside class
Submitted: 2019-04-05 04:56 UTC Modified: 2019-04-05 07:28 UTC
From: Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: master-Git-2019-04-05 (Git) OS:
Private report: No CVE-ID: None
 [2019-04-05 04:56 UTC]
In PHP 5-7.3, using __CLASS__ inside a function defined inside a class would give the name of the containing class. Also true for anonymous classes.

In 7.4 and master it is an empty string.

Test script:

class Example {

    public function __construct() {

        function example() {



new Example();


Expected result:
string(7) "Example"

Actual result:
string(0) ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-05 07:28 UTC]
-Status: Open +Status: Not a bug
 [2019-04-05 07:28 UTC]
This is an intentional change from bug #76430. A function defined inside a class has no relation to the class it is defined in. Placing the function definition inside or outside the class should have no impact on behavior.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 11 08:01:24 2021 UTC