PHP ftp_mdtm() 函数

PHP 教程 · 2019-01-26 09:13:14

定义和用法

ftp_mdtm() 函数返回指定文件的最后修改时间。

该函数将以 Unix 时间戳的形式返回文件的最后修改时间,如果出错则返回 -1。

语法

int ftp_mdtm ( resource $ftp_stream , string $remote_file )

参数 描述
ftp_connection 必需。规定要登录的 FTP 连接。
file 必需。规定要检查的文件。

提示和注释

注释:并非所有 FTP 服务器都支持该函数。

实例

<?php
$file = 'somefile.txt';

// 连接到服务器
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

//  获取最好修改时间
$buff = ftp_mdtm($conn_id, $file);
// 如果成功返回一个 UNIX 时间戳,否则返回 -1。
if ($buff != -1) {
    // 输出 somefile.txt 最后的修改时间
    echo "$file 最好修改时间为 : " . date ("F d Y H:i:s.", $buff);
} else {
    echo "无法获取文件的修改时间";
}

// 关闭连接
ftp_close($conn_id);
?>

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Build Your Own Web Site the Right Way Using HTML & CSS

Build Your Own Web Site the Right Way Using HTML & CSS

Ian Lloyd / SitePoint / 2006-05-02 / USD 29.95

Build Your Own Website The Right Way Using HTML & CSS teaches web development from scratch, without assuming any previous knowledge of HTML, CSS or web development techniques. This book introduces you......一起来看看 《Build Your Own Web Site the Right Way Using HTML & CSS》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具