PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别
PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别
$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子, 帮助确定哪些是在你的脚本最适合的。 $_SERVER[’PHP_SELF’]http://www.yoursite.com/example/ — – — /example/index.phphttp://www.yoursite.com/example/index.php — – — /example/index.phphttp://www.yoursite.com/example/index.php?a=test — – — /example/index.phphttp://www.yoursite.com/example/index.php/dir/test — – — /dir/test 当我们使用$_SERVER['PHP_SELF']的时候,无论访问的URL地址是否有index.php,它都会自动的返回 index.php.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF']。 $_SERVER['REQUEST_URI']http://www.yoursite.com/example/ — – — /http://www.yoursite.com/example/index.php — – — /example/index.phphttp://www.yoursite.com/example/index.php?a=test — – — /example/index.php?a=testhttp://www.yoursite.com/example/index.php/dir/test — – — /example/index.php/dir/test $_SERVER['REQUEST_URI']返回的是我们在URL里写的精确的地址,如果URL只写到”/”,就返回 “/” $_SERVER['SCRIPT_NAME']http://www.yoursite.com/example/ — – — /example/index.phphttp://www.yoursite.com/example/index.php — – — /example/index.phphttp://www.yoursite.com/example/index.php — – — /example/index.phphttp://www.yoursite.com/example/index.php/dir/test — – — /example/index.php 在所有的返回中都是当前的文件名/example/index.php
Copy after login
以上就是PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别的内容,更多相关内容请关注PHP中文网(www.php.cn)!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

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)
