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:
<?php $link="http://www.xxx.com/testweb/my.order.php?abcd=111@qqq=222"; $parseUrl_link=parse_url($link); print_r($parseUrl_link);
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!