求从string中取出某段值的代码。 $str = "d:/information/23/45/readme.txt";$Array = explode($str);$temp = $Array[count($Array)-1];$temp 即为最后取值! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $string = array_pop(explode("/",$str)); $str="d:/information/23/45/readme.txt";$arrpath=pathinfo($str);print_r($arrpath["basename"]);用这个吧 这个不知行不行.$str = "d:/information/23/45/readme.txt";$arr = @explode("/",$str);$end = array_pop($arr);echo $end; 各位大哥的意见都很好,可是小弟遇到另外一个麻烦,应该是说小弟表述得不太清楚。 我是想搞一个文件浏览器,最近需要根据权限来分配根目录来访问,原来只有一个根目录的情况下,只有能访问的文件就能下载,但是现在用登陆条件来改变了根目录后,发现只有跟根目录是同一个目录下的文件才能被正确下载,子目录的文件下载会出现问题,我把源文件贴上来,大家看看是怎么一回事? <?php/*This script sends to the clientthe content of a server file filename*/require("path.ini");session_start();set_time_limit(600);$crlf="\n";/* get the variable $dir*/$filename=$_GET["filename"];/*check path security*/require("lib/inc/security.inc");/*if(!file_exists("$currentpath/$filename")) { Header("Location: unreadf.php?filename="."$currentpath/$filename"); exit;}*//*check access mode*/require("explorer.cfg");$allowbrowse= $AllowSelfBrowse || !strstr($filename,basename(dirname($GLOBALS["SCRIPT_FILENAME"]))); if(!$allowbrowse) { print "sending a file from the explorer itself is forbidden (see your administrator)\n"; exit(); }// $a=basename($filename);$str=$filename;$arrpath=pathinfo($str);print_r($arrpath["basename"]);header("Content-disposition: filename=".str_replace("/",'',$arrpath["basename"]));header("Content-type: application/octet-stream");header("Pragma: no-cache");header("Expires: 0");if ($_SESSION['nas1send']==true){readfile($currentpath.'/nas1'.$filename);} echo $currentpath.'/nas1'.$filename;if ($_SESSION['nas2send']==true){readfile($currentpath.'/nas2'.$filename);}if ($_SESSION['nas3send']==true){readfile($currentpath.'/nas3'.$filename);}//echo "$crlf";//exit();?> <?php$str ="d:/information/23/45/readme.txt";echo basename($str);?> 一维数组的问题 去除重复问题 怎么学习php PHP 操作数据库因编码问题无法写入中文信息 文件上传问题,我搞了几天都没搞清楚。 php调用com问题? 怎么样保存文本输入的格式? apache2.0问题,帮我看看,谢谢~ php中有没有象asp中的application功能,我要怎么才能实现该功能?? 用"action=<?=$PHP_SELF?>"和用"action=当前的文件名"有什么不一样吗? 程序一共188行,它说我189出错?!!!! delphi 如何编写服务组件给PHP调用 求助PHP编程入门。。。
$arrpath=pathinfo($str);
print_r($arrpath["basename"]);用这个吧
我是想搞一个文件浏览器,最近需要根据权限来分配根目录来访问,原来只有一个根目录的情况下,只有能访问的文件就能下载,但是现在用登陆条件来改变了根目录后,发现只有跟根目录是同一个目录下的文件才能被正确下载,子目录的文件下载会出现问题,我把源文件贴上来,大家看看是怎么一回事?
<?php
/*This script sends to the client
the content of a server file filename*/
require("path.ini");
session_start();
set_time_limit(600);
$crlf="\n";/* get the variable $dir*/
$filename=$_GET["filename"];/*check path security*/
require("lib/inc/security.inc");/*if(!file_exists("$currentpath/$filename")) {
Header("Location: unreadf.php?filename="."$currentpath/$filename");
exit;
}*//*check access mode*/
require("explorer.cfg");$allowbrowse= $AllowSelfBrowse || !strstr($filename,basename(dirname($GLOBALS["SCRIPT_FILENAME"]))); if(!$allowbrowse) {
print "sending a file from the explorer itself is forbidden (see your administrator)\n";
exit();
}
// $a=basename($filename);
$str=$filename;
$arrpath=pathinfo($str);
print_r($arrpath["basename"]);
header("Content-disposition: filename=".str_replace("/",'',$arrpath["basename"]));header("Content-type: application/octet-stream");
header("Pragma: no-cache");
header("Expires: 0");if ($_SESSION['nas1send']==true)
{
readfile($currentpath.'/nas1'.$filename);
}
echo $currentpath.'/nas1'.$filename;if ($_SESSION['nas2send']==true)
{
readfile($currentpath.'/nas2'.$filename);
}
if ($_SESSION['nas3send']==true)
{
readfile($currentpath.'/nas3'.$filename);
}
//echo "$crlf";//exit();
?>
$str ="d:/information/23/45/readme.txt";
echo basename($str);
?>