PHP ftruncate() 函数

PHP 教程 · 2019-01-25 09:12:57

定义和用法

ftruncate() 函数把打开文件截断到指定的长度。

如果成功则返回 TRUE,如果失败则返回 FALSE。

语法


ftruncate(file,size)


参数 描述
file 必需。规定要截断的打开文件。
size 必需。规定新的文件大小。

实例


<?php
//check filesize
echo filesize("test.txt");
echo "<br />";
$file = fopen("test.txt", "a+");
ftruncate($file,100);
fclose($file);
//Clear cache and check filesize again
clearstatcache();
echo filesize("test.txt");
?>

上面的代码将输出:


792
100


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

查看所有标签

Introduction to Algorithms, 3rd Edition

Introduction to Algorithms, 3rd Edition

Thomas H. Cormen、Charles E. Leiserson、Ronald L. Rivest、Clifford Stein / The MIT Press / 2009-7-31 / USD 94.00

Some books on algorithms are rigorous but incomplete; others cover masses of material but lack rigor. Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad ......一起来看看 《Introduction to Algorithms, 3rd Edition》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具