source: branches/version-2_5-dev/data/module/Compat/tests/function/file_put_contents.phpt @ 20116

Revision 20116, 961 bytes checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
Line 
1--TEST--
2Function -- file_put_contents
3--SKIPIF--
4<?php if (function_exists('file_put_contents')) { echo 'skip'; } ?>
5--FILE--
6<?php
7require_once 'PHP/Compat.php';
8PHP_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
16echo file_put_contents($tmpfname, $string), "\n";
17echo implode('', file($tmpfname)), "\n";
18
19// With an array
20$string = array('foo', 'bar');
21
22echo file_put_contents($tmpfname, $string), "\n";
23echo implode('', file($tmpfname)), "\n";
24
25// Test append
26$string = 'foobar';
27$string2 = 'testtest';
28$tmpfname = tempnam('/tmp', 'php');
29
30echo file_put_contents($tmpfname, $string), "\n";
31echo file_put_contents($tmpfname, $string2, FILE_APPEND), "\n";
32echo implode('', file($tmpfname)), "\n";
33echo file_put_contents($tmpfname, $string2), "\n";
34echo implode('', file($tmpfname));
35
36unlink($tmpfname);
37?>
38--EXPECT--
394
40abcd
416
42foobar
436
448
45foobartesttest
468
47testtest
Note: See TracBrowser for help on using the repository browser.