2012-03-10 57 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

相關問題