PHP 输出期间的 Mpdf errơr?
Mpdf errơr during PHP output?
我有一个错误,不知道为什么。当我删除带有复选框的部分表单时,它会起作用。当我将其添加回去时出现此错误:
Warning: Cannot modify header information - headers already sent by
(output started at /footer.php:22) in mpdf/mpdf.php on line 9420 Fatal
error: Uncaught MpdfException: Some data has already been output to
browser, can't send PDF file in mpdf/mpdf.php:9422 Stack trace: #0
page-kontakt.php(421): mPDF->Output('Zamowienie2.pdf', 'D')
<?php
get_footer();
require("mpdf/mpdf.php");
require_once __DIR__ . '/mpdf/vendor/autoload.php';
if (isset($_POST['submit'])) {
$mpdf = new Mpdf('utf-8', 'A4');
$mpdf->SetDisplayMode('fullwidth');
$custom_company_data = $_POST['nazwa'];
$custom_street = $_POST['ulica'];
$custom_post_code = $_POST['kod'];
$custom_city = $_POST['miejscowosc'];
$custom_nip = $_POST['nip'];
$custom_type = $_POST['typ'];
$custom_place = $_POST['miejsce'];
$custom_date = $_POST['data'];
$custom_time = $_POST['czas'];
$custom_work_time = $_POST['worktime'];
$custom_phone = $_POST['phone'];
$custom_description = $_POST['opis'];
$custom_work = $_POST['praca'];
$custom_dojazd = $_POST['dojazd'];
$custom_ryczalt = $_POST['ryczalt'];
$custom_cash = $_POST['gotowka'];
$custom_bank_wire = $_POST['przelew'];
$custom_ile_dni=$_POST['ile_dni'];
$custom_vat = $_POST['vat'];
$custom_odwrotne = $_POST['odwrotne'];
$custom_by_post = $_POST['poczta'];
$custom_send_an_email = $_POST['elektroniczne'];
$custom_address = $_POST['naadres'];
$custom_pdf_name = date("Y-m-d") . '-' . $custom_company_data;
$custom_vat = $_POST['vat'];
$custom_odwrotne = $_POST['odwrotne'];
if(($_POST['platnosc1'])=='Gotówka'){
$platnosc='Gotówka';
}
elseif(($_POST['platnosc2'])=='Przelew w terminie'){
$platnosc='Przelewem w terminie: '.$custom_ile_dni;
}
else{
$platnosc='Nie Wybrano opcji';
}
echo $custom_company_data . '</br>';
if(($_POST['vat1']=='VAT23%')){
$vat='23%';
}
elseif(($_POST['vat2']=='Odwrotne obciazenie')){
$vat='Odwrotne obciążenie';
}
else{
echo'Nie podano formy VATU';
}
if(($_POST['wysylka1']=='poczta')){
$wysylka='Poczta';
}
elseif(($_POST['wysylka2']=='elektronicznie')){
$wysylka='Elektronicznie na e-mail: ' .$custom_address;
}
else{
echo'Nie podano formy wysyłki faktury';
}
$mpdf->SetHTMLFooter('some html footer...');
$html='some html content...';
$mpdf->WriteHTML($html);
$mpdf->Output("./wp-content/themes/xxxx/pdf/Zamowienie-$custom_pdf_name.pdf", 'F');
$mpdf->Output('Zamowienie2.pdf', 'D');
}
?>
footer.php
(可能包含在 get_footer();
中)在第 22 行输出一些内容,这会导致设置(隐式)响应 headers。这导致 $mpdf->Output('Zamowienie2.pdf', 'D');
无法再设置(相同!)响应的 headers...我猜它试图设置 MIME 类型 application/pdf
,而页脚已经设置了 MIME 类型text/html
(或类似的)。
尝试评论 get_footer()
看看是否可以解决问题。或者如果它至少改变了错误。
我有一个错误,不知道为什么。当我删除带有复选框的部分表单时,它会起作用。当我将其添加回去时出现此错误:
Warning: Cannot modify header information - headers already sent by (output started at /footer.php:22) in mpdf/mpdf.php on line 9420 Fatal error: Uncaught MpdfException: Some data has already been output to browser, can't send PDF file in mpdf/mpdf.php:9422 Stack trace: #0 page-kontakt.php(421): mPDF->Output('Zamowienie2.pdf', 'D')
<?php
get_footer();
require("mpdf/mpdf.php");
require_once __DIR__ . '/mpdf/vendor/autoload.php';
if (isset($_POST['submit'])) {
$mpdf = new Mpdf('utf-8', 'A4');
$mpdf->SetDisplayMode('fullwidth');
$custom_company_data = $_POST['nazwa'];
$custom_street = $_POST['ulica'];
$custom_post_code = $_POST['kod'];
$custom_city = $_POST['miejscowosc'];
$custom_nip = $_POST['nip'];
$custom_type = $_POST['typ'];
$custom_place = $_POST['miejsce'];
$custom_date = $_POST['data'];
$custom_time = $_POST['czas'];
$custom_work_time = $_POST['worktime'];
$custom_phone = $_POST['phone'];
$custom_description = $_POST['opis'];
$custom_work = $_POST['praca'];
$custom_dojazd = $_POST['dojazd'];
$custom_ryczalt = $_POST['ryczalt'];
$custom_cash = $_POST['gotowka'];
$custom_bank_wire = $_POST['przelew'];
$custom_ile_dni=$_POST['ile_dni'];
$custom_vat = $_POST['vat'];
$custom_odwrotne = $_POST['odwrotne'];
$custom_by_post = $_POST['poczta'];
$custom_send_an_email = $_POST['elektroniczne'];
$custom_address = $_POST['naadres'];
$custom_pdf_name = date("Y-m-d") . '-' . $custom_company_data;
$custom_vat = $_POST['vat'];
$custom_odwrotne = $_POST['odwrotne'];
if(($_POST['platnosc1'])=='Gotówka'){
$platnosc='Gotówka';
}
elseif(($_POST['platnosc2'])=='Przelew w terminie'){
$platnosc='Przelewem w terminie: '.$custom_ile_dni;
}
else{
$platnosc='Nie Wybrano opcji';
}
echo $custom_company_data . '</br>';
if(($_POST['vat1']=='VAT23%')){
$vat='23%';
}
elseif(($_POST['vat2']=='Odwrotne obciazenie')){
$vat='Odwrotne obciążenie';
}
else{
echo'Nie podano formy VATU';
}
if(($_POST['wysylka1']=='poczta')){
$wysylka='Poczta';
}
elseif(($_POST['wysylka2']=='elektronicznie')){
$wysylka='Elektronicznie na e-mail: ' .$custom_address;
}
else{
echo'Nie podano formy wysyłki faktury';
}
$mpdf->SetHTMLFooter('some html footer...');
$html='some html content...';
$mpdf->WriteHTML($html);
$mpdf->Output("./wp-content/themes/xxxx/pdf/Zamowienie-$custom_pdf_name.pdf", 'F');
$mpdf->Output('Zamowienie2.pdf', 'D');
}
?>
footer.php
(可能包含在 get_footer();
中)在第 22 行输出一些内容,这会导致设置(隐式)响应 headers。这导致 $mpdf->Output('Zamowienie2.pdf', 'D');
无法再设置(相同!)响应的 headers...我猜它试图设置 MIME 类型 application/pdf
,而页脚已经设置了 MIME 类型text/html
(或类似的)。
尝试评论 get_footer()
看看是否可以解决问题。或者如果它至少改变了错误。