Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Bug #68948: feof() on temporary streams broken --FILE-- <?php $testString = '012..

Decoded Output download

--TEST--
Bug #68948: feof() on temporary streams broken
--FILE--
<?php

$testString = '0123456789';

$stream = fopen("php://memory", "r+");
fwrite($stream, $testString);
rewind($stream);

var_dump(fread($stream, 10));
var_dump(ftell($stream));
var_dump(feof($stream));

rewind($stream);

var_dump(fread($stream, 11));
var_dump(ftell($stream));
var_dump(feof($stream));

?>
--EXPECT--
string(10) "0123456789"
int(10)
bool(false)
string(10) "0123456789"
int(10)
bool(true)

Did this file decode correctly?

Original Code

--TEST--
Bug #68948: feof() on temporary streams broken
--FILE--
<?php

$testString = '0123456789';

$stream = fopen("php://memory", "r+");
fwrite($stream, $testString);
rewind($stream);

var_dump(fread($stream, 10));
var_dump(ftell($stream));
var_dump(feof($stream));

rewind($stream);

var_dump(fread($stream, 11));
var_dump(ftell($stream));
var_dump(feof($stream));

?>
--EXPECT--
string(10) "0123456789"
int(10)
bool(false)
string(10) "0123456789"
int(10)
bool(true)

Function Calls

fopen 1
fwrite 1

Variables

$stream True
$testString 0123456789

Stats

MD5 fd01e0a72103e21bcb5d747c9387391f
Eval Count 0
Decode Time 92 ms