thinkphp常見路徑用法分析,thinkphp路徑用法_PHP教程

來源:互聯網
上載者:User

thinkphp常見路徑用法分析,thinkphp路徑用法


本文執行個體分析了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程式設計有所協助。

http://www.bkjia.com/PHPjc/920603.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/920603.htmlTechArticlethinkphp常見路徑用法分析,thinkphp路徑用法 本文執行個體分析了thinkphp常見路徑用法。分享給大家供大家參考。具體如下: 這裡介紹的標籤主要...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.