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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC