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
|
--TEST--
Bug #44818 (php://memory writeable when opened read only)
--FILE--
<?php
function test($url, $mode) {
echo "$url, $mode\n";
$fd = fopen($url, $mode);
var_dump($fd, fwrite($fd, b"foo"));
var_dump(fseek($fd, 0, SEEK_SET), fread($fd, 3));
fclose($fd);
}
test("php://memory","r");
test("php://memory","r+");
test("php://temp","r");
test("php://temp","w");
?>
--EXPECTF--
php://memory, r
resource(%d) of type (stream)
int(0)
int(0)
string(0) ""
php://memory, r+
resource(%d) of type (stream)
int(3)
int(0)
string(3) "foo"
php://temp, r
resource(%d) of type (stream)
int(0)
int(0)
string(0) ""
php://temp, w
resource(%d) of type (stream)
int(3)
int(0)
string(3) "foo"
|