2012-03-10 55 views
0

在此示例中,style.css文件的内容未写入输出字符串。我究竟做错了什么?打开文件并将其内容复制到另一个文件中

$openFile = get_theme_root() . "/" . get_template() . "/myfile.css"; 
$customcss = fopen($openFile, 'w'); 
$customcss.=file_get_contents(get_bloginfo('template_directory')."/styles/test/style.css"); 
fwrite($openFile, $customcss); 
fclose($openFile); 
+2

为什么不使用file_put_contents而不是fopen,fwrite,fclose? – 2012-03-10 16:13:16

+0

为什么不只是['copy'](http://php.net/copy)这个文件? – salathe 2012-03-10 16:45:34

回答

1

我看到下列错误:

在第2行,你把资源在$customcss(根据documentation)。然后你试图追加一个字符串(第3行),这是一个无意义的字符串。所以,只需更改第2行的var。

+0

谢谢,我相信file_put_contents是我正在寻找。 – RegEdit 2012-03-10 16:51:14

相关问题