Home>Article>Backend Development> How to get link suffix in php

How to get link suffix in php

王林
王林 Original
2019-09-21 17:57:06 4244browse

How to get link suffix in php

How to get the suffix (php) of the executed file my.order.php, 2 methods are listed for reference only:

First get it through parse_url Link information:


      

The running result is as follows:

Array ( [scheme] => http [host] => www.xxx.com [path] => /testweb/my.order.php [query] => abcd=111@qqq=222 )

Then get the file extension based on the obtained (path) information.

Method 1

Idea: Read the path information through pathinfo and the PATHINFO_EXTENSION parameter, and the output is the file extension.

echo pathinfo($parseUrl_link['path'],PATHINFO_EXTENSION );

Method 2

Idea: Get the information including the last "." and the following through strrchr, and then delete the "." on the left. , the output is the file extension.

echo ltrim(strrchr($parseUrl_link['path'],"."),".");

The above is the detailed content of How to get link suffix in php. For more information, please follow other related articles on the PHP Chinese website!

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
Previous article:How to paginate in PHP Next article:How to paginate in PHP