Share on Google+Share on Google+

PHP function ftruncate and example

Advertisement
In this segment of the PHP tutorial we will learn the ftruncate function of the file handling

Syntax

int ftruncate(file_handle,length)

  • ftruncate function truncates the file content with the given length.
  • And it returns the truncated file size.

PHP ftruncate() Function Example

Code

<?php
$file1
=fopen("bb.txt","r");
echo
"file size is ".filesize("bb.txt");
ftruncate($file1,100);
echo
"<br>now the file size is ".filesize("bb.txt");
?>

Output

file size is 300
now the file size is 200

Advertisements

Advertisement

Posted on: October 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.