有人能告诉我为什么这样不行吗?我试图让它在插件目录中创建一个文件。在我完成这项工作后,我将尝试在活动主题的目录中创建一个文件。有人能帮帮我吗?
EDIT
我已经更改了代码,现在它创建了文件,但它甚至没有将文本“Testing”输入到文件中。我有什么遗漏吗?$filename = __FILE__;
register_activation_hook($filename, \'superActivation\');
register_deactivation_hook($filename, \'superDeactivation\');
global $myFile, $fh, $stringData, $filename, $pluginbase, $full_plugindir;
$myFile = "../wp-content/themes/striking/testFile.php";
$stringData = "Testing\\n";
$fh = fopen($myFile, \'w\') or die("can\'t open file");
function superActivation() {
global $myFile; global $fh; global $stringData; global $filename;
fwrite($fh, \'test\');
fclose($fh);
}
function superDeactivation() {
global $myFile;
if(is_file("$myFile")) {
unlink("$myFile");
}
}