私人领地

php把数组、字符串 生成文件

生成的代码 data/ss.php

<?php
return  
array (
  'name' => '1111',
  'title' => '2222',
);

 

php代码

$str = "<?php\nreturn  \n";
        $myfile = fopen("data/ss.php", "w") or die("Unable to open file!");

        fwrite($myfile, $str);

        fwrite($myfile, var_export($data, true));
        fwrite($myfile, ';');
        fclose($myfile);

 

posted @ 2017-09-04 18:48  狂奔的蜗牛Snails  阅读(362)  评论(0)    收藏  举报