php-src/ext/standard/tests/file/ftruncate.phpt
2006-11-14 21:59:57 +00:00

54 lines
1.1 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--TEST--
ftruncate() tests
--FILE--
<?php
$filename = dirname(__FILE__)."/ftruncate.dat";
file_put_contents($filename, "some test data inside");
$fp = fopen($filename, "r");
var_dump(ftruncate($fp, 10));
fclose($fp);
var_dump(file_get_contents($filename));
$fp = fopen($filename, "w");
var_dump(ftruncate($fp, 10));
fclose($fp);
var_dump(file_get_contents($filename));
file_put_contents($filename, "some test data inside");
$fp = fopen($filename, "a");
var_dump(ftruncate($fp, 10));
fclose($fp);
var_dump(file_get_contents($filename));
$fp = fopen($filename, "a");
var_dump(ftruncate($fp, 0));
fclose($fp);
var_dump(file_get_contents($filename));
file_put_contents($filename, "some test data inside");
$fp = fopen($filename, "a");
var_dump(ftruncate($fp, -1000000000));
fclose($fp);
var_dump(file_get_contents($filename));
@unlink($filename);
echo "Done\n";
?>
--EXPECTF--
bool(false)
string(21) "some test data inside"
bool(true)
string(10) ""
bool(true)
string(10) "some test "
bool(true)
string(0) ""
bool(false)
string(21) "some test data inside"
Done