如何将html输出从php保存到.java文件
这是我的html输出。从.php文件如何将html输出从php保存到.java文件,php,Php,这是我的html输出。从.php文件 public class Resource { public static int cliamer = fgfgfger; public static int reporting = grgrging; } 我想将其保存到mytext.java如何使用php实现这一点: // beginning of your script ob_start(); // your script // end of your script
public class Resource {
public static int cliamer = fgfgfger;
public static int reporting = grgrging;
}
我想将其保存到mytext.java如何使用php实现这一点:
// beginning of your script
ob_start();
// your script
// end of your script
$data = ob_get_contents();
ob_end_clean(); // or ob_end_flush(); if you also want to output something
file_put_contents(dirname(__FILE__).'/mytext.java', $data);
$myData = "java code goes here";
$fp = fopen('dir/mytext.java', 'w');
fwrite($fp, $myData);
fclose($fp);
此处的主要故障点是文件夹的权限。您应该查看fwrite?我认为文件内容非常简单。为了使它更美观:
fclose($fp)代码>