Table of Contents
Url几个常用的函数,Url常用函数
Url几个常用的函数,Url常用函数
parse_url()
本函数解析一个 URL 并返回一个关联数组,包含在 URL 中出现的各种组成部分。
本函数不是用来验证给定 URL 的合法性的,只是将其分解为下面列出的部分。不完整的 URL 也被接受, parse_url() 会尝试尽量正确地将其解析。
<span>$_url</span> = "http://www.baidu.com/web?id=15&page=5"<span>; $_par = pares_url($_url); </span><span>var_dump</span>($_par);<br /><br />输出结果:
Copy after login
<span>array</span>(4<span>) { [</span>"scheme"]=> <span>string</span>(4) "http"<span> [</span>"host"]=> <span>string</span>(13) "www.baidu.com"<span> [</span>"path"]=> <span>string</span>(4) "/web"<span> [</span>"query"]=> <span>string</span>(12) "id=15&page=5"<span> }</span>
Copy after login
Copy after login
parse_str()
将字符串解析成多个变量
<span>parse_str</span>(<span>$_par</span>['query'],<span>$_query</span><span>); </span><span>var_dump</span>(<span>$_query</span><span>); 输出结果: </span><span>array</span>(2<span>) { [</span>"id"]=> <span>string</span>(2) "15"<span> [</span>"page"]=> <span>string</span>(1) "5"<span> }</span>
Copy after login
http_bulid_query()
使用给出的关联(或下标)数组生成一个经过 URL-encode 的请求字符串。
<span>unset</span>(<span>$_query</span>['page']); <span>//</span><span>清空page</span> <span>var_dump</span>(<span>http_build_query</span>(<span>$_query</span><span>)); 输出: </span><span>string</span>(5) "id=15"
Copy after login
用于解析、拆分、重组URL字符串。
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
1 months ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
4 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
4 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)
