歡迎來(lái)到奇迪科技(深圳)有限公司,超值服務(wù)提供卓越產(chǎn)品!
PHP 操作創(chuàng )建模版_網(wǎng)絡(luò )編程_奇迪科技(深圳)有限公司(m.cheanjie.com)
獲取一個(gè)模版main.html里面的內容,替換相應的內容,寫(xiě)入新模版,并且以時(shí)間命名保存。
代碼如下:
<?php $template = './main.html'; //模板文件路徑 $output = './' . date('Ymd') . '.html'; //輸出文件路徑 $replaceAry = array( //要查找替換的內容 每行一個(gè) '{title}' => '標題', ); $content = file_get_contents($template); $content = str_replace(array_keys($replaceAry), $replaceAry, $content); file_put_contents($output, $content); ?>
本文版權所有,轉載須注明:來(lái)源 http://m.cheanjie.com/qvdv-oop-24.html