尝试从 PHP 代码生成 html 文件
Trying to generate a html file from PHP code
我有一个来自 OpenEMR 的 PHP 程序,它以 HTML 格式将上下文打印到控制台。我想将它打印的任何内容保存到另一个 html 文件中。我对 PHP 和前端技术不是很熟悉。有谁知道使它工作的简单方法?非常感谢。
代码详情如下:
foreach($newpatient as $patient){
/*
$inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
while($result = sqlFetchArray($inclookupres)) {
include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
}
*/
print "<div id='superbill_patientdata'>";
print "<h1>".xlt('Patient Data').":</h1>";
printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
print "</div>";
print "<div id='superbill_insurancedata'>";
print "<h1>".xlt('Insurance Data').":</h1>";
print "<h2>".xlt('Primary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
print "<h2>".xlt('Secondary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
print "<h2>".xlt('Tertiary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
print "</div>";
print "<div id='superbill_billingdata'>";
print "<h1>".xlt('Billing Information').":</h1>";
if (count($patient) > 0) {
$billings = array();
echo "<table width='100%'>";
echo "<tr>";
echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
$total = 0.00;
$copays = 0.00;
//foreach ($patient as $be) {
$ta = split(":",$patient);
$billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
$billings[] = $billing;
foreach ($billing as $b) {
// grab the date to reformat it in the output
$bdate = strtotime($b['date']);
echo "<tr>\n";
echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
echo "<td class='text'>" . text($b['provider_name']) . "</td>";
echo "<td class='text'>";
echo text($b['code_type']) . ":\t" . text($b['code']) . " ". text($b['modifier']) . " " . text($b['code_text']) . " ";
echo "</td>\n";
echo "<td class='text'>";
echo oeFormatMoney($b['fee']);
echo "</td>\n";
echo "</tr>\n";
$total += $b['fee'];
}
// Calculate the copay for the encounter
$copays = getPatientCopay($pids[$iCounter],$ta[1]);
//}
echo "<tr><td> </td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total + abs($copays)) . "</td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Copay Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
echo "</table>";
echo "<pre>";
//print_r($billings);
echo "</pre>";
}
echo "</div>";
<?php
ob_start();
/*
你的代码
*/
$page= ob_get_contents();
if ($fp = fopen('../page.htm', 'w+')) {
fwrite ($fp, $page);
fclose($fp);
}
ob_end_flush();
?>
我有一个来自 OpenEMR 的 PHP 程序,它以 HTML 格式将上下文打印到控制台。我想将它打印的任何内容保存到另一个 html 文件中。我对 PHP 和前端技术不是很熟悉。有谁知道使它工作的简单方法?非常感谢。
代码详情如下:
foreach($newpatient as $patient){
/*
$inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
while($result = sqlFetchArray($inclookupres)) {
include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
}
*/
print "<div id='superbill_patientdata'>";
print "<h1>".xlt('Patient Data').":</h1>";
printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
print "</div>";
print "<div id='superbill_insurancedata'>";
print "<h1>".xlt('Insurance Data').":</h1>";
print "<h2>".xlt('Primary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
print "<h2>".xlt('Secondary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
print "<h2>".xlt('Tertiary').":</h2>";
printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
print "</div>";
print "<div id='superbill_billingdata'>";
print "<h1>".xlt('Billing Information').":</h1>";
if (count($patient) > 0) {
$billings = array();
echo "<table width='100%'>";
echo "<tr>";
echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
$total = 0.00;
$copays = 0.00;
//foreach ($patient as $be) {
$ta = split(":",$patient);
$billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
$billings[] = $billing;
foreach ($billing as $b) {
// grab the date to reformat it in the output
$bdate = strtotime($b['date']);
echo "<tr>\n";
echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
echo "<td class='text'>" . text($b['provider_name']) . "</td>";
echo "<td class='text'>";
echo text($b['code_type']) . ":\t" . text($b['code']) . " ". text($b['modifier']) . " " . text($b['code_text']) . " ";
echo "</td>\n";
echo "<td class='text'>";
echo oeFormatMoney($b['fee']);
echo "</td>\n";
echo "</tr>\n";
$total += $b['fee'];
}
// Calculate the copay for the encounter
$copays = getPatientCopay($pids[$iCounter],$ta[1]);
//}
echo "<tr><td> </td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total + abs($copays)) . "</td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Copay Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
echo "</table>";
echo "<pre>";
//print_r($billings);
echo "</pre>";
}
echo "</div>";
<?php
ob_start();
/* 你的代码 */
$page= ob_get_contents();
if ($fp = fopen('../page.htm', 'w+')) {
fwrite ($fp, $page);
fclose($fp);
}
ob_end_flush();
?>