- 相關推薦
分析thinkphp常見路徑用法分析
文章主要介紹了thinkphp常見路徑用法,實例分析了__PUBLIC__、__ROOT__、__APP__、__URL__、__ACTION__及__SELF__等標簽常量的用法,需要的朋友可以參考下.就跟隨百分網小編一起去了解下吧,想了解更多相關信息請持續關注我們應屆畢業生考試網!
本文實例分析了thinkphp常見路徑用法。分享給大家供大家參考。具體如下:
這里介紹的標簽主要有: __root__ __self__ __action__ __url__ __app__ __public__
假如你項目首頁的URL是:www.test.com/other/Form
假如當前模塊是:Index
假如當前操作是:index
那么首頁完整的URL:http://www.test.com/other/Form/index.php/Index/index
1 __ROOT__:/other/thinkphp/mydemo
2 __SELF__:/other/thinkphp/mydemo/Form/index.php
3 __ACTION__: /other/thinkphp/mydemo/Form/index.php/Index/index
4 __URL__: /other/thinkphp/mydemo/Form/index.php/Index
5 __APP__: /other/thinkphp/mydemo/Form/index.php
6 __PUBLIC__:/other/thinkphp/mydemo/Public
7 ../public(不區分大小寫):/other /thinkphp/mydemo/Form/Tpl/default/Public
8 APP_PUBLIC_URL:/other/thinkphp/mydemo/Form/Tpl/default/Public
9 WEB_PUBLIC_URL:/other/thinkphp/mydemo/Public
模板中對路徑部分的操作是這樣子的:
復制代碼 代碼如下:
//項目公共目錄
$tmplContent = str_ireplace('../public',APP_PUBLIC_URL,$tmplContent);
//網站公共目錄
$tmplContent = str_replace('__PUBLIC__',WEB_PUBLIC_URL,$tmplContent);
//網站根目錄
$tmplContent = str_replace('__ROOT__',__ROOT__,$tmplContent);
//當前項目地址
$tmplContent = str_replace('__APP__',__APP__,$tmplContent);
//當前模塊地址
$tmplContent = str_replace('__URL__',__URL__,$tmplContent);
//當前項目操作地址
$tmplContent = str_replace('__ACTION__',__ACTION__,$tmplContent);
//當前頁面操作地址
$tmplContent = str_replace('__SELF__',__SELF__,$tmplContent);
希望本文所述對大家基于ThinkPHP框架的PHP程序設計有所幫助。
【分析thinkphp常見路徑用法分析】相關文章:
php中引用的用法分析06-22
Java中的多態用法實例分析10-23
電腦主板常見的故障分析07-12
Flash常見動畫火苗動畫的制作分析10-09
駕照科目一考試常見錯題分析09-20
2015駕照科目一常見錯題分析08-29
英語CET6寫作常見錯誤分析07-31
高考語文常見文言虛詞用法:“之”的用法10-20
2017年專八英語寫作常見錯誤分析08-28
建造師證書掛靠常見問題分析06-14