php题目使用3中以上方法获取文件扩展名

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtfsb/article/details/78288892

<?php

//1
$file="a.jpg";
echo substr($file,strpos($file,'.')+1);

/*2
$f="a.jpg";
 echo end(explode(".",$f));
 */
/*3
$f="a.jpg";
echo array_pop(explode('.',$f));
*/
/*4
$file="a.jpg";
$a=pathinfo($file);
echo $a['extension'];
*/
/*5
$file="a.jpg";
echo strrchr($file,'.');
*/

猜你喜欢

转载自blog.csdn.net/wtfsb/article/details/78288892