我想我手上可能有一个Heisenbug。到目前为止,我的代码如下:
$enc = $_REQUEST['l'];
$filename = DecryptString($enc);
echo $filename; //Displays: uploads/Maid with the Flaxen Hair.mp3
if (is_dir($filename)) //Gives the error: "Warning: is_dir() expects parameter 1 to be a valid path, string given"
{
Download($filename);
}
然而,如果我将what作为echo'ed,即uploads/Maid with the Flaxen Hair.mp3
,并运行is_dir("uploads/Maid with the Flaxen Hair.mp3")
,它会按预期返回。
因此,如果我将变量传递到is_dir
中,它会失败,但如果我传递变量的值,它会起作用。有什么收获?
DecryptString()
返回一个末尾有NUL('0
)的字符串。
在尝试使用该值之前,请确保将其修剪掉。
您可以使用$enc = trim($enc);
修剪NULL字符