php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26953 static function in unnamed class not callable
Submitted: 2004-01-18 08:18 UTC Modified: 2005-05-02 11:33 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: alex at netflex dot nl Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.0b3 (beta3) OS: all
Private report: No CVE-ID: None
 [2004-01-18 08:18 UTC] alex at netflex dot nl
Description:
------------
It isn't posible to make a call to a static function in a class if you dont no the name of the class while you making the script:

  class gfx_tagHandler_img {

  	public static function isSupported() { return true;}

  }

  $test = "gfx_tagHandler_img";

  echo {$test}::isSupported();



I was expecting that:

  echo {$test}::isSupported();

was translated to:

  echo gfx_tagHandler_img::isSupported();

but is wasn't


can this be an feature for PHP?

tnx.


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-18 08:20 UTC] alex at netflex dot nl
changed the summary
 [2005-05-02 11:33 UTC] andrey@php.net
Use reflection API

http://php.net/manual/en/language.oop5.reflection.php

look at ReflectionClass::getMethod(string method_name) and then
ReflectionMethod::invoke()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Aug 15 13:01:28 2024 UTC