search

php中parse

Jun 06, 2016 pm 07:46 PM
20linuxparsephpCommunityforumEnter

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 php中parse_url函数用法详解: $url = phpzixue.cn/detail775.shtml"; $parts = parse_url($url); 输出: Array ( [scheme] = http [host] = [path] = / ) 又如: ?php $url = username:passwor

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  php中parse_url函数用法详解:

  $url = phpzixue.cn/detail775.shtml";

  $parts = parse_url($url);

  输出:

  Array

  (

  [scheme] => http

  [host] =>

  [path] => /

  )

  又如:

  

  $url = username:password@hostname/path?arg=value#anchor';

  print_r(parse_url($url));

  echo parse_url($url, PHP_URL_PATH);

  ?>

  输出:

  Array

  (

  [scheme] => http

  [host] => hostname

  [user] => username

  [pass] => password

  [path] => /path

  [query] => arg=value

  [fragment] => anchor

  )

  可以看到,可以很容易分解出一个URL的各个部,那如果要拿指定的部分出来的话也很容易,如

  echo parse_url($url, PHP_URL_PATH);

  就是在第二个参数中,设定如下的参数:

  PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT.

php中parse

Statement
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function