The main use of the U method in thinkphp is to complete the assembly of the URL address, the advantage of using the U method in the template instead of a fixed write dead URL is that you do not need to change any of the code in the template once your environment changes or the parameter settings change. The calling format in the template needs to be in the form of {: U (' address ', ' Parameters ' ...)}, in general, the method name in the controller, for example {: U (' LoginPage ')}. The full format is:
U (' address ', ' parameters ', ' pseudo-static ', ' whether Jump ', ' Show domain Name '). The second parameter of the U method supports passing arguments, supports both array and string definitions, and if only a string-only parameter can be defined in the first argument, the following are equivalent:
U (' blog/cate ',< span="">(' cate_id ' =>1, ' status ' =>1< span="">' blog/cate ', ' cate_id=1& Status=1 ' Blog/cate?cate_id=1&status=1< span="">')
However, it is not allowed to use the following definition to pass parameters:
U (' BLOG/CATE/CATE_ID/1/STATUS/1 ')
Depending on the URL settings of the project, the same U method call can intelligently correspond to different URL address effects, which can be seen in the configuration file convention.php:
' Url_model ' = 1, < span="">< span="">
1. Normal mode: That is, the traditional get parameters to specify the current access to the module and operation, for example: (m parameter represents the module, a operation represents the Operation )
http< span="">
2.PATHINFO mode: is the system's default URL pattern, provides the best SEO support, the system has done the environment compatible processing, so can support the majority of host environment. Corresponding to the URL pattern above, the URL access address under PathInfo mode is:
http< span="">< span="">
3.REWRITE mode: The support of rewrite rules is added on the basis of PathInfo mode, it can get rid of the entrance file index.php inside the URL address, but need to configure the rewrite rules of the Web server.
If it is Apache, you will need to add the. htaccess file to the sibling of the portal file with the following content:
< span="">%{request_filename}
< span="">-%{request_filename}
< span="">-^ (. *) $ index.php/$1 [QSA, Pt
< span="">
Next, you can access it using the following URL address:
http< span="">< span="">
You can see that index.php is hidden.
4. Compatibility mode: is used for the special environment that does not support pathinfo, the address is:
http< span="">
Compatibility mode, in conjunction with the definition of a Web server rewrite rule, can achieve the same URL effect as rewrite mode.
http://www.bkjia.com/PHPjc/752224.html www.bkjia.com true http://www.bkjia.com/PHPjc/752224.html techarticle The main use of the U method in thinkphp is to complete the assembly of the URL address, the advantage of using the U method in the template instead of the fixed write dead URL is that once your environment changes or parameter settings change ...