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-- Test fgets() function : error conditions --FILE-- <?php echo "*** Testing error c..

Decoded Output download

*** Testing error conditions ***
-- Testing fgets() with invalid length arguments --

Did this file decode correctly?

Original Code

--TEST--
Test fgets() function : error conditions
--FILE--
<?php
echo "*** Testing error conditions ***\n";

$fp = fopen(__FILE__, "r");

// invalid length argument
echo "-- Testing fgets() with invalid length arguments --\n";
$len = 0;
try {
    var_dump( fgets($fp, $len) );
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

$len = -10;
try {
    var_dump( fgets($fp, $len) );
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}
$len = 1;
var_dump( fgets($fp, $len) ); // return length - 1 always, expect false

?>
--EXPECT--
*** Testing error conditions ***
-- Testing fgets() with invalid length arguments --
fgets(): Argument #2 ($length) must be greater than 0
fgets(): Argument #2 ($length) must be greater than 0
bool(false)

Function Calls

fopen 1

Variables

$fp True
$len 0

Stats

MD5 3455318e1f58ce363400f7e52f5ef98f
Eval Count 0
Decode Time 77 ms