/** * STRRCHR-finds the last occurrence of a specified character in a string * strrpos-calculates the last occurrence of the specified string in the target string * end-points the inner pointer of the array to the last cell * pathinfo-returns information for the file path * can be To specify which cells to return by using the parameters options. * They include: Pathinfo_dirname,pathinfo_basename and Pathinfo_extension. The default is to return all units*/$url= "http://www.baidu.com/aaa/test.php";Echo"First method: \ n";Echo STRRCHR($url, ‘.‘);//. PHPEcho substr(STRRCHR($url, '. '), 1);//PHPEcho"Second method: \ n";Echo substr($url,Strrpos($url, ‘.‘) +1);Echo"Method three: \ n";Echo End(Explode(‘.‘,$url));Echo"Fourth method: \ n";$info=PathInfo($url);Echo $info[' extension '];Echo"Fifth method: \ n";Echo PathInfo($url, pathinfo_extension);
5 ways to get the file name extension in the URL