开发者

Php writing to a file / string formating / file format how to do it right?

right now I'm doing it this way:

$myFile = "config.ini";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "[scripts]\n\n[admin]\nhide_fields[] = ctr_ad_headerImg\n\n";
fwrite($fh, $stringData);
$stringData = "[widget_areas]\n0.name = \"Top Navigation\"\n0.id = top-nav\n0.description = \"Widget area at the very top of the page\"\n\n[default_colors]\nsitebg = #$sitebg\n开发者_JS百科footerbg = #$footerbg\nlink = #$link\nurl = #$url\nbg = #$bg\ntext = #$text\nborder = #$border\n\nlu_link = #$lu_link\nlu_url = #$lu_url\nlu_bg = #$lu_bg\nlu_text = #$lu_text\nlu_border = #$lu_border";
fwrite($fh, $stringData);
fclose($fh);

The problem here is that I have to keep that exact file structure, what is a better way to do this? What should I study ? Any tutorials? Thanks


To write an ini file, I would recommend using php's built in ini parser: http://php.net/manual/en/function.parse-ini-file.php
And then create ini file, write values in PHP to write the array back to the file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜