-
Notifications
You must be signed in to change notification settings - Fork 7.7k
/
gh13685.phpt
52 lines (46 loc) · 1009 Bytes
/
gh13685.phpt
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
49
50
51
52
--TEST--
GH-13685 (Unexpected null pointer in zend_string.h)
--FILE--
<?php
$contents = <<<EOS
"A", "B", "C"
"D", "E", "F"
EOS;
echo "--- Directly call fgetcsv ---\n";
$file = new SplTempFileObject;
$file->fwrite($contents);
$file->rewind();
while (($data = $file->fgetcsv(',', '"', ''))) {
var_dump((string) $file);
}
try {
var_dump((string) $file);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
echo "--- Use csv control ---\n";
$file = new SplTempFileObject;
$file->fwrite($contents);
$file->rewind();
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl(',', '"', '');
foreach ($file as $row) {
var_dump((string) $file);
}
try {
var_dump((string) $file);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
--- Directly call fgetcsv ---
string(14) ""A", "B", "C"
"
string(13) ""D", "E", "F""
Cannot read from file php://temp
--- Use csv control ---
string(14) ""A", "B", "C"
"
string(13) ""D", "E", "F""
Cannot read from file php://temp