Home > Article > Backend Development > What are the several ways to get the url extension in php
Obtaining method: 1. Use the "substr(strrchr($url,"."),1)" statement; 2. Use "substr($url,strrpos($url,'.') 1) " statement; 3. Use "pathinfo($url,PATHINFO_EXTENSION)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php gets url extension Name method
Method 1:
Method 2:
http://localhost/user [basename] => order.php [extension] => php [filename] => order ) return $p['extension']; } echo get_ext2($url); ?>
Method 3:
Method 4:
Method 5:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What are the several ways to get the url extension in php. For more information, please follow other related articles on the PHP Chinese website!