我是靠谱客的博主 矮小芝麻,最近开发中收集的这篇文章主要介绍php 查找函数定义位置,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

一种是函数,一种是类方法

<!-- lang: php -->

$func = new ReflectionFunction('showmessage');
                    
 var_dump($func->getFileName());
$func = new ReflectionMethod('classname','function');
var_dump($func->getFileName());
  1. 查询哪个函数调用了当前函数 在当前函数里面

    <!-- lang: php -->

    print_r(debug_backtrace()); 结果:`Array ( [0] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/base/CComponent.php [line] => 152 [function] => setModules [class] => CModule [object] => CWebApplication Object ( [defaultController] => index [layout] => main [controllerMap] => Array ( )

                 [catchAllRequest] => 
                 [controllerNamespace] => 
                 [_controllerPath:CWebApplication:private] => 
                 [_viewPath:CWebApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/themes/views2014
                 [_systemViewPath:CWebApplication:private] => 
                 [_layoutPath:CWebApplication:private] => 
                 [_controller:CWebApplication:private] => 
                 [_theme:CWebApplication:private] => 
                 [name] => 看房团
                 [charset] => UTF-8
                 [sourceLanguage] => en_us
                 [_id:CApplication:private] => 
                 [_basePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected
                 [_runtimePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn
                 [_extensionPath:CApplication:private] => 
                 [_globalState:CApplication:private] => 
                 [_stateChanged:CApplication:private] => 
                 [_ended:CApplication:private] => 
                 [_language:CApplication:private] => 
                 [_homeUrl:CApplication:private] => 
                 [preload] => Array
                     (
                         [0] => log
                     )
    
                 [behaviors] => Array
                     (
                     )
    
                 [_parentModule:CModule:private] => 
                 [_modulePath:CModule:private] => 
                 [_params:CModule:private] => 
                 [_modules:CModule:private] => Array
                     (
                     )
    
                 [_moduleConfig:CModule:private] => Array
                     (
                     )
    
                 [_components:CModule:private] => Array
                     (
                     )
    
                 [_componentConfig:CModule:private] => Array
                     (
                         [coreMessages] => Array
                             (
                                 [class] => CPhpMessageSource
                                 [language] => en_us
                                 [basePath] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/messages
                             )
    
                         [db] => Array
                             (
                                 [class] => CDbConnection
                             )
    
                         [messages] => Array
                             (
                                 [class] => CPhpMessageSource
                             )
    
                         [errorHandler] => Array
                             (
                                 [class] => CErrorHandler
                             )
    
                         [securityManager] => Array
                             (
                                 [class] => CSecurityManager
                             )
    
                         [statePersister] => Array
                             (
                                 [class] => CStatePersister
                             )
    
                         [urlManager] => Array
                             (
                                 [class] => CUrlManager
                             )
    
                         [request] => Array
                             (
                                 [class] => CHttpRequest
                             )
    
                         [format] => Array
                             (
                                 [class] => CFormatter
                             )
    
                         [session] => Array
                             (
                                 [class] => CHttpSession
                             )
    
                         [assetManager] => Array
                             (
                                 [class] => CAssetManager
                             )
    
                         [user] => Array
                             (
                                 [class] => CWebUser
                             )
    
                         [themeManager] => Array
                             (
                                 [class] => CThemeManager
                             )
    
                         [authManager] => Array
                             (
                                 [class] => CPhpAuthManager
                             )
    
                         [clientScript] => Array
                             (
                                 [class] => CClientScript
                             )
    
                         [widgetFactory] => Array
                             (
                                 [class] => CWidgetFactory
                             )
    
                     )
    
                 [_e:CComponent:private] => 
                 [_m:CComponent:private] => 
                 [_id:CModule:private] => 
                 [_basePath:CModule:private] => 
             )
    
         [type] => ->
         [args] => Array
             (
                 [0] => Array
                     (
                         [0] => admin
                         [1] => api
                         [2] => app
                     )
    
             )
    
     )
    

    [1] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/base/CModule.php [line] => 516 [function] => __set [class] => CComponent [object] => CWebApplication Object ( [defaultController] => index [layout] => main [controllerMap] => Array ( )

                 [catchAllRequest] => 
                 [controllerNamespace] => 
                 [_controllerPath:CWebApplication:private] => 
                 [_viewPath:CWebApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/themes/views2014
                 [_systemViewPath:CWebApplication:private] => 
                 [_layoutPath:CWebApplication:private] => 
                 [_controller:CWebApplication:private] => 
                 [_theme:CWebApplication:private] => 
                 [name] => 看房团
                 [charset] => UTF-8
                 [sourceLanguage] => en_us
                 [_id:CApplication:private] => 
                 [_basePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected
                 [_runtimePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn
                 [_extensionPath:CApplication:private] => 
                 [_globalState:CApplication:private] => 
                 [_stateChanged:CApplication:private] => 
                 [_ended:CApplication:private] => 
                 [_language:CApplication:private] => 
                 [_homeUrl:CApplication:private] => 
                 [preload] => Array
                     (
                         [0] => log
                     )
    
                 [behaviors] => Array
                     (
                     )
    
                 [_parentModule:CModule:private] => 
                 [_modulePath:CModule:private] => 
                 [_params:CModule:private] => 
                 [_modules:CModule:private] => Array
                     (
                     )
    
                 [_moduleConfig:CModule:private] => Array
                     (
                     )
    
                 [_components:CModule:private] => Array
                     (
                     )
    
                 [_componentConfig:CModule:private] => Array
                     (
                         [coreMessages] => Array
                             (
                                 [class] => CPhpMessageSource
                                 [language] => en_us
                                 [basePath] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/messages
                             )
    
                         [db] => Array
                             (
                                 [class] => CDbConnection
                             )
    
                         [messages] => Array
                             (
                                 [class] => CPhpMessageSource
                             )
    
                         [errorHandler] => Array
                             (
                                 [class] => CErrorHandler
                             )
    
                         [securityManager] => Array
                             (
                                 [class] => CSecurityManager
                             )
    
                         [statePersister] => Array
                             (
                                 [class] => CStatePersister
                             )
    
                         [urlManager] => Array
                             (
                                 [class] => CUrlManager
                             )
    
                         [request] => Array
                             (
                                 [class] => CHttpRequest
                             )
    
                         [format] => Array
                             (
                                 [class] => CFormatter
                             )
    
                         [session] => Array
                             (
                                 [class] => CHttpSession
                             )
    
                         [assetManager] => Array
                             (
                                 [class] => CAssetManager
                             )
    
                         [user] => Array
                             (
                                 [class] => CWebUser
                             )
    
                         [themeManager] => Array
                             (
                                 [class] => CThemeManager
                             )
    
                         [authManager] => Array
                             (
                                 [class] => CPhpAuthManager
                             )
    
                         [clientScript] => Array
                             (
                                 [class] => CClientScript
                             )
    
                         [widgetFactory] => Array
                             (
                                 [class] => CWidgetFactory
                             )
    
                     )
    
                 [_e:CComponent:private] => 
                 [_m:CComponent:private] => 
                 [_id:CModule:private] => 
                 [_basePath:CModule:private] => 
             )
    
         [type] => ->
         [args] => Array
             (
                 [0] => modules
                 [1] => Array
                     (
                         [0] => admin
                         [1] => api
                         [2] => app
                     )
    
             )
    
     )
    

    [2] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/base/CApplication.php [line] => 161 [function] => configure [class] => CModule [object] => CWebApplication Object ( [defaultController] => index [layout] => main [controllerMap] => Array ( )

                 [catchAllRequest] => 
                 [controllerNamespace] => 
                 [_controllerPath:CWebApplication:private] => 
                 [_viewPath:CWebApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/themes/views2014
                 [_systemViewPath:CWebApplication:private] => 
                 [_layoutPath:CWebApplication:private] => 
                 [_controller:CWebApplication:private] => 
                 [_theme:CWebApplication:private] => 
                 [name] => 看房团
                 [charset] => UTF-8
                 [sourceLanguage] => en_us
                 [_id:CApplication:private] => 
                 [_basePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected
                 [_runtimePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn
                 [_extensionPath:CApplication:private] => 
                 [_globalState:CApplication:private] => 
                 [_stateChanged:CApplication:private] => 
                 [_ended:CApplication:private] => 
                 [_language:CApplication:private] => 
                 [_homeUrl:CApplication:private] => 
                 [preload] => Array
                     (
                         [0] => log
                     )
    
                 [behaviors] => Array
                     (
                     )
    
                 [_parentModule:CModule:private] => 
                 [_modulePath:CModule:private] => 
                 [_params:CModule:private] => 
                 [_modules:CModule:private] => Array
                     (
                     )
    
                 [_moduleConfig:CModule:private] => Array
                     (
                     )
    
                 [_components:CModule:private] => Array
                     (
                     )
    
                 [_componentConfig:CModule:private] => Array
                     (
                         [coreMessages] => Array
                             (
                                 [class] => CPhpMessageSource
                                 [language] => en_us
                                 [basePath] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/messages
                             )
    
                         [db] => Array
                             (
                                 [class] => CDbConnection
                             )
    
                         [messages] => Array
                             (
                                 [class] => CPhpMessageSource
                             )
    
                         [errorHandler] => Array
                             (
                                 [class] => CErrorHandler
                             )
    
                         [securityManager] => Array
                             (
                                 [class] => CSecurityManager
                             )
    
                         [statePersister] => Array
                             (
                                 [class] => CStatePersister
                             )
    
                         [urlManager] => Array
                             (
                                 [class] => CUrlManager
                             )
    
                         [request] => Array
                             (
                                 [class] => CHttpRequest
                             )
    
                         [format] => Array
                             (
                                 [class] => CFormatter
                             )
    
                         [session] => Array
                             (
                                 [class] => CHttpSession
                             )
    
                         [assetManager] => Array
                             (
                                 [class] => CAssetManager
                             )
    
                         [user] => Array
                             (
                                 [class] => CWebUser
                             )
    
                         [themeManager] => Array
                             (
                                 [class] => CThemeManager
                             )
    
                         [authManager] => Array
                             (
                                 [class] => CPhpAuthManager
                             )
    
                         [clientScript] => Array
                             (
                                 [class] => CClientScript
                             )
    
                         [widgetFactory] => Array
                             (
                                 [class] => CWidgetFactory
                             )
    
                     )
    
                 [_e:CComponent:private] => 
                 [_m:CComponent:private] => 
                 [_id:CModule:private] => 
                 [_basePath:CModule:private] => 
             )
    
         [type] => ->
         [args] => Array
             (
                 [0] => Array
                     (
                         [runtimePath] => 
                         [viewPath] => /home/apache/www/xxx/kanfangtuan.xxx.cn/themes/views2014/
                         [name] => 看房团
                         [preload] => Array
                             (
                                 [0] => log
                             )
    
                         [import] => Array
                             (
                                 [0] => application.models.*
                                 [1] => application.components.*
                                 [2] => application.models.ar.*
                                 [3] => ext.passport.*
                                 [4] => ext.*
                             )
    
                         [defaultController] => index
                         [layout] => main
                         [modules] => Array
                             (
                                 [0] => admin
                                 [1] => api
                                 [2] => app
                             )
    
                         [components] => Array
                             (
                                 [user] => Array
                                     (
                                         [class] => WebUser
                                     )
    
                                 [urlManager] => Array
                                     (
                                         [urlFormat] => path
                                         [urlSuffix] => .html
                                         [showScriptName] => 
                                         [caseSensitive] => 1
                                         [rules] => Array
                                             (
                                                 [<module:(app|gii|api)>/] => <module>/index/index
                                                 [<module:(app|gii|api)>/<controller:w+>] => <module>/<controller>/index
                                                 [<module:(app|gii|api)>/<controller:w+>/<action:w+>/] => <module>/<controller>/<action>
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/] => index/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(?!route_)(?!p)(?!label)(?!history)(w+)>/] => <controller>/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(?!route_)(?!d{8})(?!label)(?!history)(w+)>/<action:(?!d)w+>/] => <controller>/<action>
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/route_<line_id:d+>/] => route/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/route_<line_id:d+>/<action:w+>/] => route/<action>
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/p<page:(d+)>/] => index/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/label/<label:(w+)>/] => index/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/label/<label:(w+)>/p<page:(d+)>/] => index/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(history)>/] => history/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(history)>/p<page:(d+)>/] => history/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(history)>/<date:(d{6})>/] => history/index
                                                 [http://kanfangtuan.xxx.cn/<city_enname:(?!passport)(w+)>/<controller:(history)>/<date:(d{6})>/p<page:(d+)>/] => history/index
                                                 [http://admin.kanfangtuan.xxx.cn/] => admin/index/index
                                                 [http://admin.kanfangtuan.xxx.cn/<city_enname:(?!api)(w+)>/] => admin/index/index
                                                 [http://admin.kanfangtuan.xxx.cn/<city_enname:(?!api)(w+)>/<controller:w+>/] => admin/<controller>/index
                                                 [http://admin.kanfangtuan.xxx.cn/<city_enname:(?!api)(w+)>/<controller:w+>/<action:w+>/] => admin/<controller>/<action>
                                                 [http://admin.kanfangtuan.xxx.cn/<city_enname:(?!api)(w+)>/<controller:w+>/<action:w+>/p<page:d+>/] => Array
                                                     (
                                                         [0] => admin/<controller>/<action>
                                                         [urlSuffix] => .html
                                                     )
    
                                                 [http://admin.kanfangtuan.xxx.cn/<module:(api)>/] => <module>/index/index
                                                 [http://admin.kanfangtuan.xxx.cn/<module:(api)>/<controller:w+>/] => <module>/<controller>/index
                                                 [http://admin.kanfangtuan.xxx.cn/<module:(api)>/<controller:w+>/<action:w+>/] => <module>/<controller>/<action>
                                                 [http://kanfangtuan.xxx.cn/<controller:(passport)>/] => <controller>/index
                                                 [http://kanfangtuan.xxx.cn/<controller:(passport)>/<action:w+>/] => <controller>/<action>
                                             )
    
                                     )
    
                                 [IDGenter] => Array
                                     (
                                         [class] => application.components.JIDGenter
                                         [IDGenterTableName] => id_genter
                                         [connectionID] => db
                                         [defaultValue] => Array
                                             (
                                                 [uid] => Array
                                                     (
                                                         [obj] => uid
                                                         [start_id] => 1
                                                         [step] => 1
                                                     )
    
                                                 [msg_id] => Array
                                                     (
                                                         [obj] => msg_id
                                                         [start_id] => 1
                                                         [step] => 1
                                                     )
    
                                             )
    
                                     )
    
                                 [db] => Array
                                     (
                                         [class] => JDbConnection
                                         [connectionString] => mysql:host=10.10.90.186;port=3306;dbname=house_team
                                         [emulatePrepare] => 
                                         [username] => fdbuser
                                         [password] => Wslm:11Wps
                                         [charset] => utf8
                                         [enableProfiling] => 1
                                         [enableParamLogging] => 1
                                         [enableSlave] => 1
                                         [schemaCacheID] => cache
                                         [schemaCachingDuration] => 0
                                         [slaves] => Array
                                             (
                                                 [0] => Array
                                                     (
                                                         [connectionString] => mysql:host=10.10.90.186;port=3306;dbname=house_team
                                                         [username] => fdbuser
                                                         [password] => Wslm:11Wps
                                                         [charset] => utf8
                                                         [weight] => 10
                                                     )
    
                                                 [1] => Array
                                                     (
                                                         [connectionString] => mysql:host=10.10.90.186;port=3306;dbname=house_team
                                                         [username] => fdbuser
                                                         [password] => Wslm:11Wps
                                                         [charset] => utf8
                                                         [weight] => 10
                                                     )
    
                                             )
    
                                     )
    
                                 [Memcache] => Array
                                     (
                                         [class] => JMemCache
                                         [keyPrefix] => pafangtuan_
                                         [servers] => 10.10.24.106:11211
                                     )
    
                                 [session] => Array
                                     (
                                         [class] => system.web.CCacheHttpSession
                                         [cacheID] => Memcache
                                         [cookieMode] => only
                                         [timeout] => 1200
                                     )
    
                                 [Captcha] => Array
                                     (
                                         [class] => JCaptcha
                                         [showNums] => 4
                                         [stringType] => 3
                                     )
    
                                 [Captchas] => Array
                                     (
                                         [class] => JCaptchas
                                         [showNums] => 4
                                         [stringType] => 3
                                     )
    
                                 [request] => Array
                                     (
                                         [class] => JHttpRequest
                                         [enableCookieValidation] => true
                                     )
    
                                 [securityManager] => Array
                                     (
                                         [class] => CSecurityManager
                                         [ValidationKey] => 8e695152432608eb030dab9d217d9c62
                                         [EncryptionKey] => 8e695152432608eb030dab9d217d9c62
                                     )
    
                                 [errorHandler] => Array
                                     (
                                         [errorAction] => error/error
                                     )
    
                             )
    
                         [params] => Array
                             (
                                 [adminEmail] => 
                             )
    
                     )
    
             )
    
     )
    

    [3] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/YiiBase.php [line] => 125 [function] => __construct [class] => CApplication [object] => CWebApplication Object ( [defaultController] => index [layout] => main [controllerMap] => Array ( )

                 [catchAllRequest] => 
                 [controllerNamespace] => 
                 [_controllerPath:CWebApplication:private] => 
                 [_viewPath:CWebApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/themes/views2014
                 [_systemViewPath:CWebApplication:private] => 
                 [_layoutPath:CWebApplication:private] => 
                 [_controller:CWebApplication:private] => 
                 [_theme:CWebApplication:private] => 
                 [name] => 看房团
                 [charset] => UTF-8
                 [sourceLanguage] => en_us
                 [_id:CApplication:private] => 
                 [_basePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected
                 [_runtimePath:CApplication:private] => /data/apache/www/xxx/kanfangtuan.xxx.cn
                 [_extensionPath:CApplication:private] => 
                 [_globalState:CApplication:private] => 
                 [_stateChanged:CApplication:private] => 
                 [_ended:CApplication:private] => 
                 [_language:CApplication:private] => 
                 [_homeUrl:CApplication:private] => 
                 [preload] => Array
                     (
                         [0] => log
                     )
    
                 [behaviors] => Array
                     (
                     )
    
                 [_parentModule:CModule:private] => 
                 [_modulePath:CModule:private] => 
                 [_params:CModule:private] => 
                 [_modules:CModule:private] => Array
                     (
                     )
    
                 [_moduleConfig:CModule:private] => Array
                     (
                     )
    
                 [_components:CModule:private] => Array
                     (
                     )
    
                 [_componentConfig:CModule:private] => Array
                     (
                         [coreMessages] => Array
                             (
                                 [class] => CPhpMessageSource
                                 [language] => en_us
                                 [basePath] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/messages
                             )
    
                         [db] => Array
                             (
                                 [class] => CDbConnection
                             )
    
                         [messages] => Array
                             (
                                 [class] => CPhpMessageSource
                             )
    
                         [errorHandler] => Array
                             (
                                 [class] => CErrorHandler
                             )
    
                         [securityManager] => Array
                             (
                                 [class] => CSecurityManager
                             )
    
                         [statePersister] => Array
                             (
                                 [class] => CStatePersister
                             )
    
                         [urlManager] => Array
                             (
                                 [class] => CUrlManager
                             )
    
                         [request] => Array
                             (
                                 [class] => CHttpRequest
                             )
    
                         [format] => Array
                             (
                                 [class] => CFormatter
                             )
    
                         [session] => Array
                             (
                                 [class] => CHttpSession
                             )
    
                         [assetManager] => Array
                             (
                                 [class] => CAssetManager
                             )
    
                         [user] => Array
                             (
                                 [class] => CWebUser
                             )
    
                         [themeManager] => Array
                             (
                                 [class] => CThemeManager
                             )
    
                         [authManager] => Array
                             (
                                 [class] => CPhpAuthManager
                             )
    
                         [clientScript] => Array
                             (
                                 [class] => CClientScript
                             )
    
                         [widgetFactory] => Array
                             (
                                 [class] => CWidgetFactory
                             )
    
                     )
    
                 [_e:CComponent:private] => 
                 [_m:CComponent:private] => 
                 [_id:CModule:private] => 
                 [_basePath:CModule:private] => 
             )
    
         [type] => ->
         [args] => Array
             (
                 [0] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected/config/main.php
             )
    
     )
    

    [4] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/lib/yii-1.1.14.f0fee9/framework/YiiBase.php [line] => 98 [function] => createApplication [class] => YiiBase [type] => :: [args] => Array ( [0] => CWebApplication [1] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected/config/main.php )

     )
    

    [5] => Array ( [file] => /data/apache/www/xxx/kanfangtuan.xxx.cn/index.php [line] => 63 [function] => createWebApplication [class] => YiiBase [type] => :: [args] => Array ( [0] => /data/apache/www/xxx/kanfangtuan.xxx.cn/protected/config/main.php )

     )
    

)`

转载于:https://my.oschina.net/u/242853/blog/332793

最后

以上就是矮小芝麻为你收集整理的php 查找函数定义位置的全部内容,希望文章能够帮你解决php 查找函数定义位置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(31)

评论列表共有 0 条评论

立即
投稿
返回
顶部