5 ways to get the file name extension in the URL

Source: Internet
Author: User

/** * 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.