For the U method, this post was last edited by lmq_2016 from 2015-05-0422: 57: 34. let's first talk about the problem: when someone else uses the U method in thinkphp, in this way, the & nbsp; U (verify) parameter verify is the method in a custom controller. The question is, why can this form of call be effective? below is the writing of the U method, from the U method
This post was last edited by lmq_2016 at 22:57:34 on
Let's talk about the cause of this question first: when someone else uses the U method in thinkphp, U ('verify ') is used in this way ')
The verify parameter is a custom method in a controller.
So the question is, why can this form of calling be effective? The following is the writing method of the U method. I don't know where it can be used in this way?
Function U ($ url, $ vars = '', $ suffix = true, $ redirect = false, $ domain = false ){
// Parse the URL
$ Info = parse_url ($ url );
$ Url =! Empty ($ info ['path'])? $ Info ['path']: ACTION_NAME;
// Resolve the subdomain name
If ($ domain = true ){
$ Domain = $ _ SERVER ['http _ host'];
If (C ('app _ SUB_DOMAIN_DEPLOY ') {// enable sub-domain name deployment
$ Domain = 'localhost '? 'Localhost': 'WWW '. strstr ($ _ SERVER ['http _ host'],'. ');
// 'Subdomain name' => array ('Project [/group] ');
Foreach (C ('app _ SUB_DOMAIN_RULES ') as $ key => $ rule ){
If (false === strpos ($ key, '*') & 0 === strpos ($ url, $ rule [0]) {
$ Domain = $ key. strstr ($ domain, '.'); // Generate the corresponding subdomain name
$ Url = substr_replace ($ url, '', 0, strlen ($ rule [0]);
Break;
}
}
}
}
// Parse parameters
If (is_string ($ vars) {// aaa = 1 & bbb = 2 convert to an array
Parse_str ($ vars, $ vars );
} Elseif (! Is_array ($ vars )){
$ Vars = array ();
}
If (isset ($ info ['query']) {// merge parameters in the resolution address to vars
Parse_str ($ info ['query'], $ params );
$ Vars = array_merge ($ params, $ vars );
}
// URL Assembly
$ Depr = C ('URL _ PATHINFO_DEPR ');
If ($ url ){
If (0 === strpos ($ url, '/') {// define the route
$ Route = true;
$ Url = substr ($ url, 1 );
If ('/'! = $ Depr ){
$ Url = str_replace ('/', $ depr, $ url );
}
} Else {
If ('/'! = $ Depr) {// security replacement
$ Url = str_replace ('/', $ depr, $ url );
}
// Resolve groups, modules, and operations
$ Url = trim ($ url, $ depr );
$ Path = explode ($ depr, $ url );
$ Var = array ();
$ Var [C ('Var _ action')] =! Empty ($ path )? Array_pop ($ path): ACTION_NAME;
$ Var [C ('Var _ module')] =! Empty ($ path )? Array_pop ($ path): MODULE_NAME;
If (C ('URL _ CASE_INSENSITIVE ')){
$ Var [C ('Var _ module')] = parse_name ($ VAR [C ('Var _ module')]);
}
If (C ('app _ GROUP_LIST ')){
If (! Empty ($ path )){
$ Group = array_pop ($ path );
$ Var [C ('Var _ group')] = $ GROUP;
} Else {
If (GROUP_NAME! = C ('default _ group ')){
$ Var [C ('Var _ group')] = GROUP_NAME;
}
}
}
}
}
If (C ('URL _ Model') = 0) {// Normal mode URL conversion
$ Url =/index. php .'? '. Http_build_query ($ var );
If (! Empty ($ vars )){
$ Vars = http_build_query ($ vars );
$ Url. = '&'. $ vars;
}
} Else {// PATHINFO mode or URL-compatible mode
If (isset ($ route )){
$ Url =/index. php. '/'. $ url;
} Else {
$ Url =/index. php. '/'. implode ($ depr, array_reverse ($ var ));
}
If (! Empty ($ vars) {// add parameters
$ Vars = http_build_query ($ vars );
$ Url. = $ depr. str_replace (array ('=', '&'), $ depr, $ vars );
}
If ($ suffix ){
$ Suffix = true? C ('URL _ HTML_SUFFIX '): $ suffix;
If ($ suffix ){
$ Url. = '.'. ltrim ($ suffix ,'.');
}
}
}
If ($ domain ){
$ Url = 'http: // '. $ domain. $ url;
}
If ($ redirect) // jump directly to the URL
Redirect ($ url );
Else
Return $ url;
}
// URL redirection
------ Solution ----------------------
$url = 'verify';
$info = parse_url($url);
Array
(
[Path] => verify
)
You can trace it.