>  기사  >  백엔드 개발  >  thinkphp 공통 경로 사용 분석_php 예제

thinkphp 공통 경로 사용 분석_php 예제

WBOY
WBOY원래의
2016-05-16 20:29:24994검색

이 글은 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 관련 콘텐츠에 관심이 있는 독자는 이 사이트의 특별 주제인 "ThinkPHP 입문 튜토리얼" 및 "ThinkPHP의 일반적인 방법 요약"

이 기사가 ThinkPHP 프레임워크를 기반으로 하는 모든 사람의 PHP 프로그래밍에 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.