mirror of
https://github.com/php/php-src.git
synced 2024-10-19 23:44:13 +00:00
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
--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) " |