PHP has the function get_defined_functions() which allows you to get a list of all the available system and user defined functions in an array. This post looks at how to use the get_defined_functions() function, the output from it and how to sort the list into alphabetical order.
Using get_defined_functions()
get_defined_functions() returns an array containing two keys: 'internal' and 'user'. Each key contains a sub array containing a complete list of the available internal/system functions and the user defined functions respectively.
The following example illustrates this (the examples below assume we have two user defined functions called foo() and bar()):
and an extract of the result:
Sorting the result into alphabetical order
If you want to sort the list of functions into alphabetical order, you could do this instead:
and an extract of the result:
Conclusion
The get_defined_functions() function is a great way of getting a complete list of functions that are available on your install of PHP and from your own and 3rd party PHP libraries.
0 comments:
Post a Comment