


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.

随着网络技术的发展,PHP已经成为了Web开发的重要工具之一。而其中一款流行的PHP框架——CodeIgniter(以下简称CI)也得到了越来越多的关注和使用。今天,我们就来看看如何使用CI框架。一、安装CI框架首先,我们需要下载CI框架并安装。在CI的官网(https://codeigniter.com/)上下载最新版本的CI框架压缩包。下载完成后,解压缩

说明:location中的root和aliasroot指令只是将搜索的根设置为root设定的目录,即不会截断uri,而是使用原始uri跳转该目录下查找文件aias指令则会截断匹配的uri,然后使用alias设定的路径加上剩余的uri作为子路径进行查找location中的proxy_pass的uri如果proxy_pass的url不带uri如果尾部是"/",则会截断匹配的uri如果尾部不是"/",则不会截断匹配的uri如果proxy_pass的url带uri

PHP是一种流行的编程语言,广泛应用于Web开发。CI(CodeIgniter)框架是PHP中最受欢迎的框架之一,它提供了一整套现成的工具和函数库,以及一些流行的设计模式,让开发人员能够更加高效地开发Web应用程序。本文将介绍使用CI框架开发PHP应用程序的基本步骤和方法。了解CI框架的基本概念和结构在使用CI框架之前,我们需要先了解一些基本的概念和结构。下

PHP是一种广泛使用的服务器端脚本语言,而CodeIgniter4(CI4)是一个流行的PHP框架,它提供了一种快速而优秀的方法来构建Web应用程序。在这篇文章中,我们将通过引导您了解如何使用CI4框架,来使您开始使用此框架来开发出众的Web应用程序。1.下载并安装CI4首先,您需要从官方网站(https://codeigniter.com/downloa

1、介绍location指令是http模块当中最核心的一项配置,根据预先定义的url匹配规则来接收用户发送的请求,根据匹配结果,将请求转发到后台服务器、非法的请求直接拒绝并返回403、404、500错误处理等。2、location指令语法location[=|~|~*|^~|@]/uri/{…}或location@name{…}3、uri匹配模式location指令分为两种匹配模式:1>普通字符串匹配:以=开头或开头无引导字符(~)的规则2>正则匹配:以~或~*开头表示正则匹配,~*

随着互联网的发展和不断地融入人们的生活,网络应用的开发变得越来越重要。PHP作为一种众所周知的编程语言,已经成为了开发互联网应用程序的首选语言之一。而开发人员们可以使用众多的PHP框架来简化开发过程,其中最受欢迎的之一是CodeIgniter(CI)框架。CI是一个强大的PHPweb应用框架,它拥有轻量级、简单易用、优化性能等特点,可以让开发人员快速地构建

CI框架中引入CSS样式的步骤如下:1、准备CSS文件;2、将CSS文件存储在CI框架项目的适当位置;3、在需要使用CSS样式的页面中,通过HTML的<link>标签引入CSS文件;4、在HTML元素中使用CSS类或ID名称来应用相应的样式即可。

URL和URI之间的区别是:1、URI是用于标识互联网上的资源的字符串序列,而URI并不关注资源的位置,而只关注它的标识符;2、URL提供了关于资源在互联网上位置的详细信息,而URI是一种更广义的概念,不仅涵盖了URL,还包括了用于标识资源的其他形式,如URN;3、URL是URI的一种特殊类型,用于定位互联网上的资源,而URI则是一种更广义的标识符,用于唯一地标识和命名资源。


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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
