Home > php教程 > php手册 > 生成符合tp标准的返回数组配置文件

生成符合tp标准的返回数组配置文件

WBOY
Release: 2016-06-07 11:38:38
Original
1147 people have browsed it

配合系统默认配置文件中配置配置文件扩展'LOAD_EXT_CONFIG' => 'user,db', 实现应用后台化配置.好用请点个赞:)
function SaveRouteConfig()<br> {<br>     $result = D('route')->select();//来源可以为数据库<br>     foreach ($result as $v) {//路由规则一维数组<br>         $rule[$v['path']] = $v['module'];<br>     }<br>     $arr = array(//配置文件数组<br>         'URL_ROUTER_ON' => true,<br>         'URL_ROUTE_RULES' => $rule,<br>     );//<br>     $string = "<?php \r\n//后台配置生成,请注意\r\nreturn " . var_export($arr, true) . &#039;;&#039;;//php语法格式化输出<br />     $re = fopen('Common/Conf/route.php', 'wb');<br>     fwrite($re, $string);<br>     fclose($re);//将内容写入文件<br> }例子为实现脚本配置路由.最后生成<?php <br /> //后台配置生成,请注意<br> return array(<br>     'URL_ROUTER_ON' => true,<br>     'URL_ROUTE_RULES' =><br>         array(<br>             'path' => 'module',<br>         ),<br> );这种符合tp配置文件标准的文件,主要方便在脚本中生成配置数组,然后原样输出到文件.

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template