生成的代码 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);