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 str_pad() function : usage variations - large values for '$pad_length' argum..
Decoded Output download
--TEST--
Test str_pad() function : usage variations - large values for '$pad_length' argument
--SKIPIF--
<?php
if (getenv("USE_ZEND_ALLOC") === "0") {
die("skip Zend MM disabled");
}
?>
--FILE--
<?php
/* Test str_pad() function: with unexpected inputs for '$pad_length'
* and expected type for '$input'
*/
echo "*** Testing str_pad() function: with large value for for 'pad_length' argument ***
";
//defining '$input' argument
$input = "Test string";
$extra_large_pad_length = PHP_INT_MAX*5;
try {
var_dump( str_pad($input, $extra_large_pad_length) );
} catch (\TypeError $e) {
echo $e->getMessage() . "
";
}
$php_int_max_pad_length = PHP_INT_MAX;
var_dump( str_pad($input, $php_int_max_pad_length) );
?>
--EXPECTF--
*** Testing str_pad() function: with large value for for 'pad_length' argument ***
str_pad(): Argument #2 ($length) must be of type int, float given
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
Did this file decode correctly?
Original Code
--TEST--
Test str_pad() function : usage variations - large values for '$pad_length' argument
--SKIPIF--
<?php
if (getenv("USE_ZEND_ALLOC") === "0") {
die("skip Zend MM disabled");
}
?>
--FILE--
<?php
/* Test str_pad() function: with unexpected inputs for '$pad_length'
* and expected type for '$input'
*/
echo "*** Testing str_pad() function: with large value for for 'pad_length' argument ***\n";
//defining '$input' argument
$input = "Test string";
$extra_large_pad_length = PHP_INT_MAX*5;
try {
var_dump( str_pad($input, $extra_large_pad_length) );
} catch (\TypeError $e) {
echo $e->getMessage() . "\n";
}
$php_int_max_pad_length = PHP_INT_MAX;
var_dump( str_pad($input, $php_int_max_pad_length) );
?>
--EXPECTF--
*** Testing str_pad() function: with large value for for 'pad_length' argument ***
str_pad(): Argument #2 ($length) must be of type int, float given
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
Function Calls
getenv | 1 |
Stats
MD5 | 432b3f2ead08d6b56fc197720a2d6188 |
Eval Count | 0 |
Decode Time | 113 ms |