Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a called functions list in PHP

Tags:

php

In PHP, get_included_files() returns an array with the names of included files.

In a similar fashion, is there any way to get an array with the names of called functions with parameters?

like image 479
Pradip Avatar asked Oct 07 '10 12:10

Pradip


People also ask

How can I get caller function in PHP?

In PHP, a function is declared with the function keyword prefixed with the function name and the calling of a function in a program is done by just calling the name of the function wherever required.

What is function call PHP?

PHP function is a piece of code that can be reused many times. It can take input as argument list and return value. There are thousands of built-in functions in PHP. In PHP, we can define Conditional function, Function within Function and Recursive function also.

How many functions are there in PHP?

How Many Functions Are in PHP? PHP has over 700 functions you can use for various tasks.

How do you get the number of arguments passed to a PHP function?

To get the number of arguments that were passed into your function, call func_num_args() and read its return value. To get the value of an individual parameter, use func_get_arg() and pass in the parameter number you want to retrieve to have its value returned back to you.


2 Answers

In this way, Is any way to get an array with the names of called functions with parameters?

No.

What you can do is a debug_backtrace() which will show all the function calls (with parameters) that lead to the execution of the line you are doing the backtrace from (the "call stack"), but that's different from all functions that were ever called in the script.

What do you want to do? Maybe there's a different approach.

like image 70
Pekka Avatar answered Oct 03 '22 18:10

Pekka


I was searching for something similar and found xdebug's tracing very useful.

Here's an example of how it could look like: http://devzone.zend.com/1135/tracing-php-applications-with-xdebug/

like image 36
SimonSimCity Avatar answered Oct 03 '22 19:10

SimonSimCity