php使用正则表达式处理路径,源代码如下:
<html>
<body>
<?php
if (isset($_POST[\'posted\'])) {
$path = $_POST[\'path\'];
$outpath = ereg_replace(\"\\.[\\.]+\", \"\", $path);
$outpath = ereg_replace(\"^[\\/]+\", \"\", $outpath);
$outpath = ereg_replace(\"^[A-Za-z][:\\|][\\/]?\", \"\", $outpath);
/* http://www.manongjc.com/article/1319.html */
echo \"The old path is \" . $path . \" and the new path is \" . $outpath;
}
?>
<form action=\"<?php echo $_SERVER[\'PHP_SELF\']; ?>\" method=\"POST\">
<input type=\"hidden\" name=\"posted\" value=\"true\">
Enter your file path for cleaning:
<input type=\"text\" name=\"path\" size=\"30\">
<input type=\"submit\" value=\"Clean\">
</form>
</body>
</html> 继续阅读与本文标签相同的文章
-
PS保存图片提示“无法完成请求”,这里有4种解决方法!
2026-05-14栏目: 教程
-
想买1000元左右的5G手机?我们需要等多久?
2026-05-14栏目: 教程
-
剧情反转?美企主动购买华为5G技术,华为成赞赏排行榜第一名!
2026-05-14栏目: 教程
-
城市数字化后,新一代内生安全系统可全方位保护
2026-05-14栏目: 教程
-
谷歌也来“唱衰”5G,5G手机只会徒增功耗?为何这么说?
2026-05-14栏目: 教程
