[英]Find out where custom PHP function is defined
我使用內部函數function_exists
,該function_exists
可以返回true
但在項目中找不到自定義函數。 我還調試了代碼以跟蹤該函數,但是調試器沒有進入我的自定義函數。 我非常期待知道為什么。 請幫助我,謝謝。
要找出函數定義的位置,請使用以下代碼:
<?php
$rf = new ReflectionFunction('my_fuction_name');
echo 'file:' . $rf->getFileName() . ', line:' . $rf->getStartLine();
?>
請注意,如果該函數未在源代碼中定義,而是內部PHP函數,則getFileName()
和getStartLine()
都將返回false
。
您可以通過以下方式檢查該函數是否是內部函數:
<?php
$rf = new ReflectionFunction('my_fuction_name');
if($rf->isInternal() === TRUE){
echo "Function is internal!";
}else{
echo "Function is not internal.";
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.