Home >Backend Development >PHP Tutorial >php 3 functions to get file suffix name

php 3 functions to get file suffix name

WBOY
WBOYOriginal
2016-07-25 09:08:10841browse
  1. //方法一:

  2. function extend_1($file_name)
  3. {
  4. $retval="";
  5. $pt=strrpos($file_name, ".");
  6. if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
  7. return ($retval);
  8. }

  9. //方法二

  10. function extend_2($file_name)
  11. {
  12. $extend = pathinfo($file_name);
  13. $extend = strtolower($extend["extension"]);
  14. return $extend;
  15. }

  16. //方法三

  17. function extend_3($file_name)
  18. {
  19. $extend =explode("." , $file_name);
  20. $va=count($extend)-1;
  21. return $extend[$va];
  22. }
  23. ?>

复制代码


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