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 readlink() and realpath() functions: error conditions --SKIPIF-- <?php if (s..

Decoded Output download

--TEST--
Test readlink() and realpath() functions: error conditions
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
    die('skip not for Windows');
}
?>
--FILE--
<?php
echo "
*** Testing readlink() on a non-existent link ***
";
var_dump( readlink(__DIR__."/readlink_error.tmp") );

echo "
*** Testing readlink() on existing file ***
";
var_dump( readlink(__FILE__) );

echo "
*** Testing readlink() on existing directory ***
";
var_dump( readlink(__DIR__) );

echo "
*** Testing realpath() on a non-existent file ***
";
var_dump( realpath(__DIR__."/realpath_error.tmp") );

echo "Done
";
?>
--EXPECTF--
*** Testing readlink() on a non-existent link ***

Warning: readlink(): No such file or directory in %s on line %d
bool(false)

*** Testing readlink() on existing file ***

Warning: readlink(): Invalid argument in %s on line %d
bool(false)

*** Testing readlink() on existing directory ***

Warning: readlink(): Invalid argument in %s on line %d
bool(false)

*** Testing realpath() on a non-existent file ***
%s
Done

Did this file decode correctly?

Original Code

--TEST--
Test readlink() and realpath() functions: error conditions
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
    die('skip not for Windows');
}
?>
--FILE--
<?php
echo "\n*** Testing readlink() on a non-existent link ***\n";
var_dump( readlink(__DIR__."/readlink_error.tmp") );

echo "\n*** Testing readlink() on existing file ***\n";
var_dump( readlink(__FILE__) );

echo "\n*** Testing readlink() on existing directory ***\n";
var_dump( readlink(__DIR__) );

echo "\n*** Testing realpath() on a non-existent file ***\n";
var_dump( realpath(__DIR__."/realpath_error.tmp") );

echo "Done\n";
?>
--EXPECTF--
*** Testing readlink() on a non-existent link ***

Warning: readlink(): No such file or directory in %s on line %d
bool(false)

*** Testing readlink() on existing file ***

Warning: readlink(): Invalid argument in %s on line %d
bool(false)

*** Testing readlink() on existing directory ***

Warning: readlink(): Invalid argument in %s on line %d
bool(false)

*** Testing realpath() on a non-existent file ***
%s
Done

Function Calls

None

Variables

None

Stats

MD5 591886a41ec358331657d717e70fa4e2
Eval Count 0
Decode Time 99 ms