|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-11-24 10:10 UTC] Mike_G at ufamts dot ru
Description:
------------
I suggest changing get_functions_defined() function to have flag/option to return user function by includes/requires.
Example:
#require1.php
<?php
function one()
{
return 1;
}
function two()
{
return 2;
}
?>
#require2.php
<?php
function three()
{
return 3;
}
function four()
{
return 4;
}
?>
#main code
<?php
require_once('require1.php');
require_once('require2.php');
$fn_arr = get_functions_defined(true); // true - is enabled return user function by
// includes and requires.
print_r($fn_arr);
?>
Output result:
Array ( [internal] => Array (
...
),
[user] => Array (
[require1.php] => Array ([0] => 'one', [1] => 'two'),
[require2.php] => Array ([0] => 'three', [1] => 'four'),
))
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 20:00:01 2025 UTC |
Closing as this information can already be easily obtained using Reflection: foreach (get_defined_functions()['user'] as $function) { echo $function, ' defined in ', (new ReflectionFunction($function))->getFileName(); } I don't see a reason to add an argument for this to get_defined_functions() as it is a rather narrow use case.