CI Framework source code interpretation of uri.php _fetch_uri_string () function usage analysis, ciuristring
This example describes the use of _fetch_uri_string () functions in CI framework uri.php. Share to everyone for your reference, as follows:
apppath/config/config.php in the URL format.
$config [' uri_protocol '] = ' AUTO ';
This configuration item defines which server global variable you use to formulate the URL.
The default setting is auto, which polls the following four ways. When your link doesn't work, try using an option outside of 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 the 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 URIs segments
Gets the current URI string assigned to $uri _string, via function _set_uri_string ($STR).
There are several options for getting to $str, which is the business process part of _fetch_uri_string ()
First, the default
$config [' uri_protocol '] = ' AUTO '
, the program polls the following ways to get the URI at a time
(1) When the program is running under the CLI, that is, the php file at the command line. CI will get the URI so
Private Function _parse_cli_args () { $args = array_slice ($_server[' argv '), 1); Return $args? '/'. Implode ('/', $args): ';}
$_server[' argv ' contains parameters passed to the script when the script runs on the CLI, it gives command-line arguments in c format
Intercept all parameters except the first one in $_server[' argv ']
If you do this on the command line
PHP D:\wamp\www\CodeIgniter\index.php\start\index
_parse_cli_args () returns a/index.php/start/index string
(2) The default is to use Request_uri to detect URLs when the private function is called _detect_uri ()
(3) If the above two methods can not get to the URI then the $_server[' Path_info ' will be used to obtain
$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, then 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) The above four methods can not get to the URI, then we must use the $_get array, no recruit
if (Is_array ($_get) && count ($_get) = = 1 && trim (key ($_get), '/')! = ') { $this->_set_uri_string ( Key ($_get)); return;}
Second, in the config.php set up:
$config [' Uri_protocol ']
Then the program will automatically take the appropriate action to get the URI
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
http://www.bkjia.com/PHPjc/1127854.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127854.html techarticle CI Framework Source code interpretation of the uri.php _fetch_uri_string () function usage analysis, ciuristring This example describes the CI framework uri.php _fetch_uri_string () function usage. Share to everyone ...