php中获取资料后缀名多种方法

WBOY
Release: 2016-06-13 10:38:40
Original
740 people have browsed it

php中获取文件后缀名多种方法

一,php explode函数,函数用法参考??代码如下 复制代码
$pic = 'abc.php';
$pics = explode('.' , $pic);

echo $num = count($pics);
echo '
'.$pics[$num-1];
?

这样就可以输出
.php了。

下面利用foreach? 此函数用法??代码如下 复制代码
foreach ($pics as $value) //2
{
? $a = $value;
}
echo $a.'
';
?

来有一个比较好的函数end我推荐使用此函数快捷 end函数用法??代码如下 复制代码
echo end($pics);
echo '
';
?

其它的访方法可以在文件上传时判断,不过那需要文件上传不上传我们不能使用$_FILES来操作。

更多详细内容请查看:http://www.111cn.net/phper/php/42034.htm

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template