The U method is used to complete the assembly of URL addresses, which is characterized by the ability to automatically generate corresponding URL addresses based on the current URL pattern and settings, in the following format:
U (' address ', ' parameters ', ' pseudo-static ', ' whether Jump ', ' Show domain name ');
The advantage of using the U method instead of a fixed write dead URL in a template is that once your environment changes or the parameter settings change, you don't need to change any of the code in the template.
The call format in the template needs to take the form {: U (' address ', ' Parameters ' ...)}
U (' user/add ')//Generate Add Action address for User module
U (' home/user/add ')//Generate the Add action address of the User module for the Home group
U (' add ')//Generate Add action address for current access module
U (' blog/read?id=1 ')//Generate a read operation for the Blog module and a URL address with ID 1
U (' Blog/read ', array (' ID ' =>1) '//array to implement
Of course it can be done.
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 ', Array (' cate_id ' =>1, ' status ' =>1)) u (' blog/cate ', ' Cate_id=1&status=1 ') u (' Blog/cate?cate_ Id=1&status=1 ')
However, it is not allowed to use the following definition to pass parameters:
U (' BLOG/CATE/CATE_ID/1/STATUS/1 ')
If more than one pseudo-static support is set, the first pseudo-static suffix is automatically appended to the URL address, but you can also manually specify the pseudo-static suffix to be generated in the U method, for example:
U (' Blog/read ', ' id=1 ', ' xml ')
implementation of the U-method of the Thinkphp development series-Simple implementation URL