|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2015-06-26 12:36 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2015-06-26 12:36 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 22:00:01 2025 UTC |
Description: ------------ variables static class::method (with autoload support) maybe useful to wrap native vs php implementation (using function_exists) with clean O(1) code if (function_exists('native_f')) $f = 'native_f'; else $f = 'class::static_f'; // some other file... { global $f; $f($args); } // current workaround (slow 'n dirty) $f = function() { return forward_static_call_array('class::static_f',func_get_args()); }; Test script: --------------- maybe_or_not.class.php: class maybe_or_not { public static function f($a, $b) { return $a + $b; } } index.php: spl_autoload_extensions('.class.php'); spl_autoload_register(); $f = "maybe_or_not::f"; printf("%d\n",$f(1,1)); // DON'T WORK (even if the class is already loaded) Expected result: ---------------- 2 Actual result: -------------- PHP Fatal error: Call to undefined function maybe_or_not::f() in index.php