msgbartop
PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 – 左手代码 右手诗
msgbarbottom

22 Aug 08 寻找函数定义在哪个模块

今天遇到一个问题,需要查看一个函数是定义在哪个模块的, 从而去定位这个模块,翻看其源码。因为我们的环境还不容许使用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'


分享到:



Random Posts:

9 Responses to “寻找函数定义在哪个模块”

  1. Peggy |

    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.

  2. http://www.poolsafely.gov/ |

    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!!

  3. lxylxy888666 |

    仅能够找函数,结构语言就找不到,比如echo

  4. laruence |

    php手册:

    Description
    array get_loaded_extensions ( void )

  5. Mark long |

    $funcs = get_extension_funcs($m);

    此句会出现非数组的警告,应该改为:

    $funcs = (array)get_extension_funcs($m);

  6. Anonymous |

    ,,,,因为我们的环境还不容许使用Reflection APIS, 就直接写脚本了, 没什么大用,就是挺有意思的,;)

  7. xyz |

    C:\>php --rf array_search
    Function [ <internal:standard> function array_search ] {

    – Parameters [3] {
    Parameter #0 [ $needle ]
    Parameter #1 [ $haystack ]
    Parameter #2 [ $strict ]
    }
    }

  8. xyz |

    C:\>php –rf array_search
    Function [ function array_search ] {

    – Parameters [3] {
    Parameter #0 [ $needle ]
    Parameter #1 [ $haystack ]
    Parameter #2 [ $strict ]
    }
    }

  9. 雪候鸟 |

    哦? 受教了,谢谢,呵呵。

  10. NoAngels |

    发现这段代码貌似有点问题:因为不是每个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;
    }
    }
    }

Leave a Reply

*