博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php文件路径获取文件名
阅读量:4601 次
发布时间:2019-06-09

本文共 899 字,大约阅读时间需要 2 分钟。

物理截取:

$file = '/www/htdocs/inc/lib.inc.php';$filename = basename($file);echo $filename, '
';// lib.inc.php$filename = str_replace(strrchr($filename, '.'), '', $filename);echo $filename, '
';// lib.inc

使用pathinfo($path, $options):

$file = '/www/htdocs/inc/lib.inc.php';$path_parts = pathinfo($file);echo '目录名称' . $path_parts['dirname'], '
'; // /www/htdocs/incecho '文件全名' . $path_parts['basename'], '
'; // lib.inc.phpecho '文件后缀' . $path_parts['extension'], '
';// phpecho '文件名称' . $path_parts['filename'], '
'; // lib.inc // PHP >= 5.2.0echo '目录名称' . pathinfo($file, PATHINFO_DIRNAME), '
'; // /www/htdocs/incecho '文件全名' . pathinfo($file, PATHINFO_BASENAME), '
'; // lib.inc.phpecho '文件后缀' . pathinfo($file, PATHINFO_EXTENSION), '
';// phpecho '文件名称' . pathinfo($file, PATHINFO_FILENAME), '
'; // lib.inc // PHP >= 5.2.0

转载于:https://www.cnblogs.com/sgm4231/p/9796876.html

你可能感兴趣的文章
bzoj 5289: [Hnoi2018]排列
查看>>
joomla处境堪忧
查看>>
Jquery-AJAX
查看>>
mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
查看>>
LeetCode55 Jump Game
查看>>
poj 3764 The xor-longest Path (01 Trie)
查看>>
预备作业01
查看>>
【Spark】Spark-Redis连接池
查看>>
【云计算】使用supervisor管理Docker多进程-ntpd+uwsgi+nginx示例最佳实践
查看>>
Ubuntu16.04下配置ssh免密登录
查看>>
实验二 2
查看>>
will-change属性
查看>>
android学习笔记54——ContentProvider
查看>>
Unity3d android开发之触摸操作识别-双击,滑动去噪处理
查看>>
Custom view * is not using the 2- or 3-argument View constructors; XML attributes will not work
查看>>
模型选择准则
查看>>
安卓动态增加按钮
查看>>
iOS7程序后台运行
查看>>
maven+testng+reportng的pom设置
查看>>
IT telephone interview
查看>>