[关闭]
@zhutoulwz 2015-03-19T01:15:06.000000Z 字数 545 阅读 1505

PHP学习笔记

php path_info 文件处理


获取文件扩展名

  1. $path = "./image/me.jpg";
  2. $path_info = pathinfo($path);
  3. var_dump($path_info);
  4. $basename = $path_info['basename'];
  5. $ext = $path_info['extension'];
  6. $dirname = $path_info['dirname'];
  7. $filename = $path_info['filename'];
  8. // 添加参数获取特定的值
  9. $dir = pathinfo($path, PATHINFO_DIRNAME); //目录
  10. $base = pathinfo($path, PATHINFO_BASENAME); //文件名(含扩展名)
  11. $ext = pathinfo($path, PATHINFO_EXTENSION); //扩展名
  12. $filename = pathinfo($path, PATHINFO_FILENAME); // 文件名(不含扩展名,PHP>5.2)
  13. echo "<br/>";
  14. echo $dir;
  15. echo "<br/>";
  16. echo $base;
  17. echo "<br/>";
  18. echo $ext;
  19. echo "<br/>";
  20. echo $filename;
  21. echo "<br/>";
  22. ?>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注