Home >php教程 >php手册 >PHP获取文件拓展名的几种方式

PHP获取文件拓展名的几种方式

WBOY
WBOYOriginal
2016-06-06 19:57:131427browse

文件名: test.php 获取拓展名(php)的方法: 1.strrchr($filename, .); 2.substr($filename, strrpos($filename, .)) 3.array_pop(explode(., $filename)); 4.$p = pathinfo($filename); echo $p[extension]; 参考: 1.http://www.phpddt.com/php/761.html 2.

文件名: test.php

获取拓展名(php)的方法:


 1.strrchr($filename, '.');
 2.substr($filename, strrpos($filename, '.'))
 3.array_pop(explode('.', $filename));
 4.$p = pathinfo($filename);
   echo $p['extension'];

参考:

1. http://www.phpddt.com/php/761.html

2. http://www.phpddt.com/php/php-sina-test.html

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