Rumah  >  Artikel  >  rangka kerja php  >  TP框架独享PATHINFO模式?当然不!

TP框架独享PATHINFO模式?当然不!

藏色散人
藏色散人ke hadapan
2021-10-20 15:46:232168semak imbas

是否有过这样的疑问?

thinkphp中有四种URL模式,PATHINFO模式是thinkphp特有的吗?laravel中是不是不存在这样的概念?

往下看!!!

pathinfo当然不是某个框架特有的,pathinfo严格上讲是HTTP服务器提供的一个预定义变量,在许多的框架中有一个重要的组件叫做路由器,这个组件可以通过使用pathinfo来实现。

考虑以下代码:

# filename:./testpathinfo.php
<?php
echo $_SERVER[&#39;PATH_INFO&#39;];

当我直接请求该文件时(留意地址栏):

http://localhost/testpathinfo.php

1e9406c56205dcd9341c278681b876f.png

若文件未得到pathinfo参数时未定义该值,这时如果我这样请求(留意地址栏):

http://localhost/testpathinfo.php/this/is/path/info?a=1&b=2

9da08ccf0cd97556693545bcf5c8761.png

所以,该功能配合rewrite功能可实现去除地址中的请求文件。

另外,PHP提供名为pathinfo()的函数,用于提取路径的信息:

推荐:《最新的10个thinkphp视频教程

Atas ialah kandungan terperinci TP框架独享PATHINFO模式?当然不!. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Artikel ini dikembalikan pada:segmentfault.com. Jika ada pelanggaran, sila hubungi admin@php.cn Padam