我正在使用一个很棒的WP主题。之所以存在问题,是因为它总是针对以下行$handle = fopen($tmpfname, "w+");
和if( fwrite($handle, "<?php\n" . $phpCode))
显示错误,表明该文件为空。
我该怎么办?我在下面添加的错误。
function setup_theme_temp($phpCode)
{
//create a temporary filename
$tmpfname = tempnam(sys_get_temp_dir(), "setup_theme_temp");
//open the new file URL
$handle = fopen($tmpfname, "w+");
if( fwrite($handle, "<?php\n" . $phpCode))
{
}
else
{
$tmpfname = tempnam('./', "setup_theme_temp");
$handle = fopen($tmpfname, "w+");
fwrite($handle, "<?php\n" . $phpCode);
}
fclose($handle);
include $tmpfname;
unlink($tmpfname);
return get_defined_vars();
}
错误
Warning: fopen(): Filename cannot be empty in
Warning: fwrite() expects parameter 1 to be resource, boolean given