admin 发表于 2020-11-22 15:15:07

ThinkPHP,四、模板内置默认的输出替换规则修改__ROOT__、__UR...


<p class="MsoNormal" align="left"><span style="font-size:12.0pt;font-family:彩虹粗仿宋;
mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">在<span lang="EN-US">\thinkphp\library\think</span>目录下的<span lang="EN-US">view.php</span>文件中,内置了默认的模板输出替换规则<span lang="EN-US"><o:p></o:p></span></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">$baseReplace
= [<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '__ROOT__'&nbsp;&nbsp; =&gt; $root,<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '__URL__'&nbsp;&nbsp;&nbsp; =&gt; $base . '/' . $request-&gt;module() .
'/' . Loader::parseName($request-&gt;controller()),<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '__STATIC__' =&gt; $root .
'/static',<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '__CSS__'&nbsp;&nbsp;&nbsp; =&gt; $root . '/static/css',<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;'__JS__'&nbsp;&nbsp;&nbsp;&nbsp;
=&gt; $root . '/static/js',<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ];<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt"><o:p>&nbsp;</o:p></span></p><p class="MsoNormal" align="left"><span style="font-size:12.0pt;font-family:彩虹粗仿宋;
mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">如果需要修改默认的输出替换规则,不要直接修改<span lang="EN-US">view.php</span>文件,可以在配置文件中修改<span lang="EN-US"><o:p></o:p></span></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">//
</span><span style="font-size:12.0pt;font-family:彩虹粗仿宋;mso-bidi-font-family:
MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">视图输出字符串内容替换<span lang="EN-US"><o:p></o:p></span></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">'view_replace_str'
=&gt; [<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">'__PUBLIC__'=&gt;'/public/',<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">'__ROOT__'
=&gt; '/',<o:p></o:p></span></p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">]<o:p></o:p></span></p><p class="MsoNormal" align="left"><span style="font-size:12.0pt;font-family:彩虹粗仿宋;
mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">也可以在代码中直接修改<span lang="EN-US">return $this-&gt;fetch('index',[],['__PUBLIC__'=&gt;'/public/']);<o:p></o:p></span></span></p><p class="MsoNormal" align="left"><span style="font-size:12.0pt;font-family:彩虹粗仿宋;
mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">助手函数<span lang="EN-US">view </span>也支持全局配置参数<span lang="EN-US">view_replace_str </span>的设置,如果需要设置不同的替换参数,可以使用:<span lang="EN-US"><o:p></o:p></span></span></p><p class="MsoNormal" align="left">

































</p><p class="MsoNormal" align="left"><span lang="EN-US" style="font-size:12.0pt;font-family:
彩虹粗仿宋;mso-bidi-font-family:MicrosoftYaHei;color:#525252;mso-font-kerning:0pt">return
view('index',['name'=&gt;'thinkphp'],['__PUBLIC__'=&gt;'/public/']);<o:p></o:p></span></p>

winwin99 发表于 2022-5-23 16:10:16

如果需要设置不同的替换参数,可以使用:幸运飞艇直播,福彩双色球结果,幸运时时彩走势图
页: [1]
查看完整版本: ThinkPHP,四、模板内置默认的输出替换规则修改__ROOT__、__UR...