php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46659 I suggest changing get_functions_defined() function function
Submitted: 2008-11-24 10:10 UTC Modified: 2012-09-23 16:37 UTC
From: Mike_G at ufamts dot ru Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Mike_G at ufamts dot ru
New email:
PHP Version: OS:

 

 [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'),
))


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-23 16:37 UTC] nikic@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2012-09-23 16:37 UTC] nikic@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 08:01:34 2025 UTC