ftp_mdtm

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_mdtm返回指定文件的最后修改時(shí)間

說(shuō)明

ftp_mdtm(resource $ftp_stream, string $remote_file): int

ftp_mdtm() 獲取遠(yuǎn)程文件的最后修改時(shí)間。

注意:

某些 FTP 服務(wù)器可能會(huì)不支持這個(gè)特性!

注意:

ftp_mdtm() 不適用于檢查目錄。

參數(shù)

ftp_stream

FTP 連接句柄。

remote_file

要檢查的遠(yuǎn)程文件。

返回值

返回指定文件的最后修改時(shí)間,以 UNIX 時(shí)間戳的方式返回。如果發(fā)生錯(cuò)誤,或文件不存在則返回 -1。

范例

示例 #1 ftp_mdtm() 示例

<?php

$file 
'somefile.txt';

// set up basic connection
$conn_id ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

//  get the last modified time
$buff ftp_mdtm($conn_id$file);

if (
$buff != -1) {
    
// somefile.txt was last modified on: March 26 2003 14:16:41.
    
echo "$file was last modified on : " date("F d Y H:i:s."$buff);
} else {
    echo 
"Couldn't get mdtime";
}

// close the connection
ftp_close($conn_id);

?>