File: file_get_contents_file_put_contents_variation2.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (48 lines) | stat: -rw-r--r-- 2,552 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--TEST--
Test file_get_contents() and file_put_contents() functions : usage variations - use_include_path
--FILE--
<?php

/* Testing variation using use_include_path argument */
$file_path = __DIR__;
include($file_path."/file.inc");

echo "*** Testing with variation in use_include_path argument ***\n";
$dir = "file_get_contents_variation2";
mkdir($file_path."/".$dir);
$filename = $file_path."/".$dir."/"."file_get_contents_variation2.tmp";

ini_set( 'include_path',$file_path."/".$dir );

$data_array = array( 1, "  Data1 in an array", 2, "  Data2 in an array" );
fill_buffer( $buffer, "text", 100);
file_put_contents( $filename, $buffer );
fill_buffer( $buffer, "numeric", 100);
file_put_contents( $filename, $buffer, FILE_APPEND, NULL );
file_put_contents( $filename, $data_array, FILE_APPEND, NULL );
var_dump( file_get_contents($filename, 0) );
var_dump( file_get_contents($filename, 1) );
var_dump( file_get_contents($filename, 0, NULL, 5) );
var_dump( file_get_contents($filename, 1, NULL, 5) );
var_dump( file_get_contents($filename, 0, NULL, 5, 20) );
var_dump( file_get_contents($filename, 1, NULL, 5, 20) );

echo "--- Done ---";
?>
--CLEAN--
<?php
//Deleting the temporary files and directory used in the testcase

$file_path = __DIR__;
unlink($file_path."/file_get_contents_variation2/file_get_contents_variation2.tmp");
rmdir($file_path."/file_get_contents_variation2");
?>
--EXPECT--
*** Testing with variation in use_include_path argument ***
string(240) "text text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221  Data1 in an array2  Data2 in an array"
string(240) "text text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221  Data1 in an array2  Data2 in an array"
string(235) "text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221  Data1 in an array2  Data2 in an array"
string(235) "text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221  Data1 in an array2  Data2 in an array"
string(20) "text text text text "
string(20) "text text text text "
--- Done ---