CI framework Source Code explanation: URI. php _ fetch_uri_string () function usage analysis, ciuristring_PHP tutorial

Source: Internet
Author: User
CI framework Source Code explanation: URI. php's _ fetch_uri_string () function usage analysis, ciuristring. Description of the CI framework source code: URI. php's _ fetch_uri_string () function usage analysis. ciuristring this article describes the CI framework URI. php's _ fetch_uri_string () function usage. I will share with you the usage analysis of the _ fetch_uri_string () function in URI. php for the CI framework source code, ciuristring

This article describes the use of the _ fetch_uri_string () function in the CI framework URI. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.