Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Function -- file_put_contents
3
--SKIPIF--
4
<?php if (function_exists('file_put_contents')) { echo 'skip'; } ?>
5
--FILE--
6
<?php
7
require_once 'PHP/Compat.php';
8
PHP_Compat::loadFunction('file_put_contents');
9
 
10
// Create a temp file
11
$tmpfname = tempnam('/tmp', 'phpcompat');
12
 
13
// With a string
14
$string = "abcd";
15
 
16
echo file_put_contents($tmpfname, $string), "\n";
17
echo implode('', file($tmpfname)), "\n";
18
 
19
// With an array
20
$string = array('foo', 'bar');
21
 
22
echo file_put_contents($tmpfname, $string), "\n";
23
echo implode('', file($tmpfname)), "\n";
24
 
25
// Test append
26
$string = 'foobar';
27
$string2 = 'testtest';
28
$tmpfname = tempnam('/tmp', 'php');
29
 
30
echo file_put_contents($tmpfname, $string), "\n";
31
echo file_put_contents($tmpfname, $string2, FILE_APPEND), "\n";
32
echo implode('', file($tmpfname)), "\n";
33
echo file_put_contents($tmpfname, $string2), "\n";
34
echo implode('', file($tmpfname));
35
 
36
unlink($tmpfname);
37
?>
38
--EXPECT--
39
4
40
abcd
41
6
42
foobar
43
6
44
8
45
foobartesttest
46
8
47
testtest