当我从我的数据库中获取内容时,它会将单引号显示为ISO代码而不是'。我尝试了各种类型的编码和解码,但似乎没有任何效果。
它显示'
而不是单引号。
这是从数据库中获取数据的文件
<?php
include 'core/init.php';
login_check($mysqli);
user_data_check($mysqli);
$data = totaal_factuur_data_1($mysqli, $_GET['ref']);
$kost = totaal_factuur_data_2($mysqli, $_GET['ref']);
include 'factuur.php';
$pdf->Output($data[0] . '.pdf', 'I');
?>
这是factuur.php文件。
<?php
define('EURO',chr(128));
$hoog = 0;
$laag = 0;
$totaal = explode('<br>', $kost[0]);
foreach($kost as $key => $value) {
if($key != 0) {
if ($value[2] == 21) {
$hoog++;
}
if ($value[2] == 6) {
$laag++;
}
}
}
if($hoog > 0) {
if ($laag > 0) {
$toteen = EURO . punt_naar_komma($totaal[0]) . "\n" . EURO . punt_naar_komma($totaal[1]). "\n" . EURO . punt_naar_komma($totaal[2]). "\n" . EURO . punt_naar_komma($totaal[3]);
$tottwee = "Bedrag:\n6% BTW:\n21% BTW:\nTotaal:";
} else {
$toteen = EURO . punt_naar_komma($totaal[0]) . "\n" . EURO . punt_naar_komma($totaal[1]) . "\n" . EURO . punt_naar_komma($totaal[2]);
$tottwee = "Bedrag:\n21% BTW:\nTotaal:";
}
} elseif($laag > 0) {
$toteen = EURO . punt_naar_komma($totaal[0]) . "\n" . EURO . punt_naar_komma($totaal[1]). "\n" . EURO . punt_naar_komma($totaal[2]);
$tottwee = "Bedrag:\n6% BTW:\nTotaal:";
} else {
$toteen = EURO . punt_naar_komma($totaal[0]) . "\n" . EURO . punt_naar_komma($totaal[1]);
$tottwee = "Bedrag:\nTotaal:";
}
require('fpdf.php');
class PDF extends FPDF
{
function FancyTable($data)
{
$this->SetFillColor(100,100,100);
$this->SetTextColor(255,255,255);
$this->SetDrawColor(100,100,100);
$this->SetLineWidth(.1);
$this->SetFontSize(11);
$this->SetFont('','B');
$this->Cell(115,7,'Omschijving',1,0,'L',true);
$this->Cell(35,7,'Btw tarief',1,0,'C',true);
$this->Cell(40,7,'Bedrag',1,0,'R',true);
$this->Ln();
$this->SetFillColor(214,214,214);
$this->SetTextColor(0);
$this->SetFont('');
$fill = false;
foreach($data as $key => $row)
{
$output_data = str_replace("_", " ", $row[4]);
if($key != 0) {
$this->Cell(115,6,$output_data,'LR',0,'L',$fill);
if($row[2] == 6 || $row[2] == 21 || $row[2] == 0) {
$this->Cell(35,6,$row[2] . '%','LR',0,'C',$fill);
} else {
$this->Cell(35,6,$row[2],'LR',0,'C',$fill);
}
$this->Cell(40,6,EURO . punt_naar_komma($row[0]),'LR',0,'R',$fill);
$this->Ln();
$fill = !$fill;
}
}
$this->Cell(190 ,0,'','T');
}
function Header()
{
$data = $GLOBALS['data'];
$klant_data = explode('^', $data[3]);
if($data[8] == 0) {
$titel = 'Factuur';
} else if($data[8] == 1) {
$titel = 'Creditnota';
} if($data[8] == 2) {
$titel = 'Offerte';
}
if(strlen($klant_data[5]) < 2) {
$this->SetFont('Arial','b',24);
$this->Cell(35, 40, $titel, '', '', 'L');
$this->Ln(50);
} else {
$this->Image('/home/deb60170n7/domains/ezboekhouding.nl/data/settings/' . $klant_data[5],10,10,'', 40);
$this->SetFont('Arial','b',14);
$this->Ln(25);
$this->Cell(155, 0, $titel, '', '0', 'R');
$this->Ln(25);
}
$klant .= $klant_data[0] . "\n";
$klant .= $klant_data[1] . "\n";
$klant .= $klant_data[2] . "\n";
$klant .= $klant_data[3] . ' ' . $klant_data[4];
$klant = utf8_decode($klant);
$adres_data= explode('^', $data[4]);
if($data[1] != '*') {
$adres .= 'T.a.v. ' . $data[1] . "\n";
}
$adres .= $adres_data[0] . "\n";
$adres .= $adres_data[1] . "\n";
$adres .= $adres_data[2] . " " . $adres_data[3];
$this->SetFont('Arial','',12);
$x = $this->GetX();
$y = $this->GetY();
$this->SetTextColor(100,100,100);
$this->MultiCell(90, '5', $klant , '0', 'L');
$this->SetXY($x + 105, $y);
$this->SetTextColor(0,0,0);
$this->MultiCell(90, '5', $adres , '0', 'L');
$this->Ln(15);
$this->Cell(35, 0, 'Factuur datum:', '', '', 'L');
$this->Cell(70, 0, $data[2]);
$this->Cell(30, 0, 'BTW nummer:', '', '', 'R');
$this->Cell(30, 0, $data[6]);
$this->Ln(5);
$this->Cell(35, 0, 'Factuur nummer:', '', '', 'L');
$this->Cell(70, 0, $data[0]);
$this->Cell(30, 0, 'KVK nummer:', '', '', 'R');
$this->Cell(30, 0, $data[7]);
$this->Ln(5);
$this->Cell(0,0,'',1);
$this->Ln(5);
}
function Footer()
{
$data = $GLOBALS['data'];
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$adres_data= explode('^', $data[3]);
if($data[8] == 0) {
$text = 'Wij verzoeken u het bedrag zo snel mogelijk over te maken naar rekeningnummer ' . $data[5] . ' t.n.v. ' . $adres_data[6] . ' o.v.v. het factuur nummer.';
} else if($data[8] == 1) {
$text = '';
} if($data[8] == 2) {
$text = '';
}
$this->Cell(0,'', $text, 0, 0, 'C');
$this->Ln();
$this->Cell(0,10,'Pagina '.$this->PageNo(),0,0,'C');
}
}
$pdf = new PDF();
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->FancyTable($kost);
$pdf->Ln(1);
$pdf->Cell(115);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(35, '5', $tottwee , '', 'R');
$pdf->SetXY($x + 35, $y);
$pdf->MultiCell(40, '5', $toteen , '', 'R');
?>
有人能告诉我解码这个的正确方法吗?我也试过设置
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
带有所有标准html引号的但是fpdf类给出了一些错误,即某些数据已经输出并且无法显示pdf文件。
我试图在Header函数中解码它。我不知道这对解码有什么影响,比如iconv或utf8_decode?。我认为问题是别的,因为我也尝试在文件中进行解码,该文件使用for循环从数据库获取数据。
提前致谢!