<?php
$file = "test.txt";
if (!unlink($file))
{
echo ("Error deleting $file");
}
else
{
echo ("Deleted $file");
}
?>
php可以获得站点的根目录
function GetRootPath()
{
$sRealPath = realpath( './' ) ;
$sSelfPath = $_SERVER['PHP_SELF'] ;
$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ;
}
通过$_SERVER["DOCUMENT_ROOT"]变量取虚拟目录
转载于:https://www.cnblogs.com/kaixin110/archive/2009/02/19/1393906.html