- 本文地址: https://www.laruence.com/2008/08/22/404.html
- 转载请注明出处
今天遇到一个问题,需要查看一个函数是定义在哪个模块的, 从而去定位这个模块,翻看其源码。因为我们的环境还不容许使用Reflection APIS, 就直接写脚本了, 没什么大用,就是挺有意思的,;)
get_function_container.php <?php $function_name = $argv[1]; $modules = get_loaded_extensions(); foreach($modules as $m){ $funcs = get_extension_funcs($m); if(in_array($function_name, $funcs)){ printf("%s was defined in Module: %s\n", $function_name, $m);; exit; } } print $function_name ." Must be defined in user defined PHP script files\n"; ?>
使用方法:
php -f get_function_container.php 'function_name'
有点意思~~
非常感谢您的分享
marijuana for sale on the internet herbal mood elevators euphoric drugs herbal smoke high legal haoinclnlgeus smoke what are the best extacy pills herbal extasy buy k2 or spice buy legal bud. where can i get salvia in florida salvia uliginosa seeds legal natural party drugs spice alternative to cannabis bzp free party pills spike 99 buy where to buy skunk legal where to buy poppers in australia party pills perth. where to buy legal highs in brighton white butterfly extacy legal highs west yorkshire.
Great web site you have here (http://www.poolsafely.gov/)..
It’s difficult to find good quality writing like yours these days.
I really appreciate people like you! Take care!!
仅能够找函数,结构语言就找不到,比如echo
$funcs = get_extension_funcs($m);
此句会出现非数组的警告,应该改为:
$funcs = (array)get_extension_funcs($m);
php手册:
Description
array get_loaded_extensions ( void )
,,,,因为我们的环境还不容许使用Reflection APIS, 就直接写脚本了, 没什么大用,就是挺有意思的,;)
C:\>php --rf array_search
Function [ <internal:standard> function array_search ] {
– Parameters [3] {
Parameter #0 [ $needle ]
Parameter #1 [ $haystack ]
Parameter #2 [ $strict ]
}
}
哦? 受教了,谢谢,呵呵。
发现这段代码貌似有点问题:因为不是每个module用get_extension_funcs返回的都是数组,所以可以改动代码如下:
<?php
$function_name = $argv[1];
$modules = get_loaded_extensions();
foreach($modules as $m){
$funcs = get_extension_funcs($m);
if (is_array($funcs)){
if(in_array($function_name, $funcs)){
printf(“%s was defined in Module: %s\n”, $function_name, $m);;
exit;
}
}
}