浏览文章
文章信息
【WelineFrame框架】框架开发之模板引擎:PHP追踪debug_backtrace获得调用当前方法的父方法
28239
M框架代码示例:
/** * @DESC |获取模板渲染 * @Author 秋枫雁飞/Aiweline * @email aiweline@qq.com * 参数区: * * @param string $fileName * @return bool * @throws Exception */ protected function fetch(string $fileName = null) { if ($fileName == null) { $parent_call_info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]; $fileNameArr = explode(\M\Framework\Controller\Data\DataInterface::dir, $parent_call_info['class']); $fileName = trim(array_pop($fileNameArr), '\\') . DIRECTORY_SEPARATOR . $parent_call_info['function']; }; return $this->_template->fetch($fileName); }仓库地址:https://gitee.com/Aiweline_admin/WelineFramework
微蓝WelineFramework框架!
测试环境:http://m.dev.aiweline.com/
注意:dev开发环境下把防跨站攻击关闭。