Assume that the home page URL of your project is: Homepage...
Assume that the Homepage URL of your project is www.test.com/other/Form.
If the current module is: Index
If the current operation is: index
Then the home page complete URL: http://www.test.com/other/Form/index.php/Index/index
_ ROOT __:/other/thinkphp/mydemo
_ SELF __:/other/thinkphp/mydemo/Form/index. php
_ ACTION __:/other/thinkphp/mydemo/Form/index. php/Index/index
_ URL __:/other/thinkphp/mydemo/Form/index. php/Index
_ APP __:/other/thinkphp/mydemo/Form/index. php
_ PUBLIC __:/other/thinkphp/mydemo/Public
../Public (case insensitive):/other/thinkphp/mydemo/Form/Tpl/default/Public
APP_PUBLIC_URL:/other/thinkphp/mydemo/Form/Tpl/default/Public
WEB_PUBLIC_URL:/other/thinkphp/mydemo/Public
The path operation in the template is like this. PHP code:
- // Project Public Directory
- $ TmplContent = str_ireplace ('../public', APP_PUBLIC_URL, $ tmplContent );
- // Public website directory
- $ TmplContent = str_replace ('_ PUBLIC _', WEB_PUBLIC_URL, $ tmplContent );
- // Website root directory
- $ TmplContent = str_replace ('_ ROOT _' ,__ ROOT __, $ tmplContent );
- // Current project address
- $ TmplContent = str_replace ('_ APP _' ,__ APP __, $ tmplContent );
- // Address of the current module
- $ TmplContent = str_replace ('_ URL _' ,__ URL __, $ tmplContent );
- // Operation address of the current project
- $ TmplContent = str_replace ('_ ACTION _' ,__ ACTION __, $ tmplContent );
- // Operation address on the current page
- $ TmplContent = str_replace ('_ SELF _' ,__ SELF __, $ tmplContent );
Test URL: http: // localhost/blog/testurl. php? Id = 5
- // Obtain the domain name or host address
- Echo $ _ SERVER ['http _ host']."
- "; # Localhost
-
- // Obtain the webpage address
- Echo $ _ SERVER ['php _ SELF ']."
- "; #/Blog/testurl. php
-
- // Obtain URL parameters
- Echo $ _ SERVER ["QUERY_STRING"]."
- "; # Id = 5
-
- // Obtain the user proxy
- Echo $ _ SERVER ['http _ referer']."
- ";
-
- // Obtain the complete url
- Echo 'http: // '. $ _ SERVER ['http _ host']. $ _ SERVER ['request _ url'];
- Echo 'http: // '. $ _ SERVER ['http _ host']. $ _ SERVER ['php _ SELF']. '? '. $ _ SERVER ['query _ string'];
- # Http: // localhost/blog/testurl. php? Id = 5
-
- // Complete url containing the port number
- Echo 'http ://'. $ _ SERVER ['server _ name']. ':'. $ _ SERVER ["SERVER_PORT"]. $ _ SERVER ["REQUEST_URI"];
- # Http: // localhost: 80/blog/testurl. php? Id = 5
-
- // Only take the path
- $ Url = 'http: // '. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"];
- Echo dirname ($ url );
- # Http: // localhost/blog