getcwd()
函數在 PHP 中用于獲取當前工作目錄的路徑
然而,如果你需要獲取網絡上的某個目錄,你可以使用 fopen()
或 file_get_contents()
等函數與 URL 結合來實現。例如:
$url = 'http://example.com/path/to/directory/';
$handle = fopen($url, 'r');
if ($handle) {
$directory = stream_get_contents($handle);
fclose($handle);
echo $directory;
} else {
echo '無法打開 URL';
}
這段代碼將嘗試打開指定的 URL,并將內容讀取到 $directory
變量中。請注意,這種方法可能會受到跨域資源共享(CORS)限制,具體取決于目標服務器的設置。