This article mainly introduces the URI of the CI framework source code. in php, The _ fetch_uri_string () function is used to analyze the URL Routing Mechanism in the CI framework and the related config configuration file setting methods based on the instance form, for more information about the CI framework URI, see the example in this article. use the _ fetch_uri_string () function in php. We will share this with you for your reference. The details are as follows:
The url format in APPPATH/config. php.
$config['uri_protocol'] = 'AUTO';
This configuration item defines which server global variable you use to draw up a URL.
The default setting is auto, and round robin is performed in the following four methods. When your link cannot work, try to use an option other than auto.
'Auto' Default-AUTO detects
'Path _ info' Uses the PATH_INFO
'Query _ string' Uses the QUERY_STRING
'Request _ URI 'Uses the REQUEST_URI
'Orig _ PATH_INFO 'Uses the ORIG_PATH_INFO
Several member variables in CI_URI
$keyval = array(); //List of cached uri segments$uri_string; //Current uri string$segments //List of uri segments$rsegments = array() //Re-indexed list of uri segments
The obtained current uri string is assigned to $ uri_string through function _ set_uri_string ($ str ).
Several options are available for getting $ str, that is, the business flow section of _ fetch_uri_string ().
I. Default
$config['uri_protocol'] = 'AUTO'
The program polls the following method at a time to obtain the URI
(1) When the program runs under CLI, that is, the PHP file under the command line. Ci will get the URI like this
private function _parse_cli_args(){ $args = array_slice($_SERVER['argv'], 1); return $args ? '/' .implode('/',$args) : '';}
$ _ SERVER ['argv'] contains the parameters passed to the script. When the script runs in CLI, the c-format command line parameters are provided.
All parameters except the first in $ _ SERVER ['argv ']
If you perform this operation in the command line
php d:\wamp\www\CodeIgniter\index.php\start\index
_ Parse_cli_args () returns a/index. php/start/index string.
(2) The Private function _ detect_uri () is called by default when REQUEST_URI is used to detect a url ()
(3) If neither of the preceding methods can obtain the uri, $ _ SERVER ['path _ info'] is used to obtain the uri.
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');if (trim($path, '/') != '' && $path != "/".SELF){ $this->_set_uri_string($path); return;}
(4) If none of the above three methods can be obtained, use
$ _ SERVER ['query _ string'] Or getenv ['query _ string']
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');if (trim($path, '/') != ''){ $this->_set_uri_string($path); return;}
(5) If no URI can be obtained from the above four methods, use the $ _ GET array.
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != ''){ $this->_set_uri_string(key($_GET)); return;}
2. Set in config. php:
$config['uri_protocol']
The program automatically performs the corresponding operation to obtain the uri.