求从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中_POST获取值, 不存在时,怎么验证 jquery ajax 返回json问题.... php结合flash显示图片 大负数转换,singed -> unsigned 很无奈的一个下拉框的问题 php 更改特定txt文件内容 phpMyAdmin-2.6-rc1 有问题! 使用php的mail()函数一定要在web服务器上装mail服务器嘛? 菜鸟求救!关于提交表单变量名称的问题! php整合apache后出错 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);
?>