


CI framework source code interpretation of _fetch_uri_string() function usage analysis in URI.php, ciuristring_PHP tutorial
CI framework source code interpretation of _fetch_uri_string() function usage analysis in URI.php, ciuristring
The example of this article describes the usage of _fetch_uri_string() function in CI framework URI.php. Share it with everyone for your reference, the details are as follows:
The formulation of url format in APPPATH/config/config.php.
$config['uri_protocol'] = 'AUTO';
This configuration item defines which server global variables you use to formulate URLs.
The default setting is auto, which will poll the following four methods. When your link doesn't work, try using 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).
There are several options to get $str, which is the business process part of _fetch_uri_string()
1. Default
$config['uri_protocol'] = 'AUTO'
, the program will poll the following methods once to obtain the URI
(1) When the program is run under CLI, that is, when the php file is under the command line. ci will get 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 is run on the CLI, the command line parameters in c format will be given
Intercept all parameters in $_SERVER['argv'] except the first one
If you do this from the command line
php d:\wamp\www\CodeIgniter\index.php\start\index
_parse_cli_args() returns a string of /index.php/start/index
(2) By default, when REQUEST_URI is used to detect the url, the private function _detect_uri()
will be called.(3) If neither of the above two methods can obtain the uri, $_SERVER['PATH_INFO'] will be used to obtain it
$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) If the above four methods cannot obtain the URI, then you have to use the $_GET array, there is no other way
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']
Then the program will automatically perform the corresponding operations to obtain the uri
Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With the development of network technology, PHP has become one of the important tools for Web development. One of the popular PHP frameworks - CodeIgniter (hereinafter referred to as CI) has also received more and more attention and use. Today, we will take a look at how to use the CI framework. 1. Install the CI framework First, we need to download the CI framework and install it. Download the latest version of the CI framework compressed package from CI's official website (https://codeigniter.com/). After the download is complete, unzip

Note: The root and aliasroot instructions in location only set the search root to the directory set by root, that is, the uri will not be truncated. Instead, the original uri will be used to jump to the directory to find the file. The aias instruction will truncate the matching uri, and then Use the path set by alias plus the remaining uri as a sub-path to find the uri of proxy_pass in location. If the url of proxy_pass does not have uri, if the tail is "/", the matching uri will be truncated. If the tail is not "/", then Will not truncate the matching uri if the proxy_pass url contains uri

PHP is a popular programming language that is widely used in web development. The CI (CodeIgniter) framework is one of the most popular frameworks in PHP. It provides a complete set of ready-made tools and function libraries, as well as some popular design patterns, allowing developers to develop Web applications more efficiently. This article will introduce the basic steps and methods of developing PHP applications using the CI framework. Understand the basic concepts and structures of the CI framework. Before using the CI framework, we need to understand some basic concepts and structures. Down

PHP is a widely used server-side scripting language, and CodeIgniter4 (CI4) is a popular PHP framework that provides a fast and excellent way to build web applications. In this article, we will get you started using the CI4 framework to develop outstanding web applications by walking you through how to use it. 1. Download and install CI4 First, you need to download it from the official website (https://codeigniter.com/downloa

1. Introduction The location directive is the core configuration of the http module. It receives requests sent by users based on predefined URL matching rules. Based on the matching results, the request is forwarded to the backend server. Illegal requests are directly rejected and return 403. 404, 500 error handling, etc. 2. Location instruction syntax location[=|~|~*|^~|@]/uri/{…} or location@name{…} 3. URI matching mode The location instruction is divided into two matching modes: 1> Ordinary characters String matching: rules starting with = or without leading characters (~) 2> Regular matching: starting with ~ or ~* indicates regular matching, ~*

With the development of the Internet and its continuous integration into people's lives, the development of network applications has become more and more important. As a well-known programming language, PHP has become one of the preferred languages for developing Internet applications. Developers can use numerous PHP frameworks to simplify the development process, one of the most popular is the CodeIgniter (CI) framework. CI is a powerful PHP web application framework. It has the characteristics of lightweight, easy to use, optimized performance, etc., allowing developers to quickly build

The steps to introduce CSS styles in the CI framework are as follows: 1. Prepare CSS files; 2. Store the CSS files in the appropriate location of the CI framework project; 3. In the pages that need to use CSS styles, introduce CSS through the HTML <link> tag File; 4. Use the CSS class or ID name in the HTML element to apply the corresponding style.

The difference between URL and URI is: 1. URI is a sequence of strings used to identify resources on the Internet, while URI does not focus on the location of the resource, but only on its identifier; 2. URL provides information about the location of the resource. Detailed information about a location on the Internet, while URI is a broader concept that covers not only URLs, but also other forms used to identify resources, such as URN; 3. URL is a special type of URI, used for location A resource on the Internet, while a URI is a broader identifier used to uniquely identify and name a resource.
