fpdf是不是working/connecting到localhost?

Fpdf is not working/connecting to localhost?

我有一个 PHP 文件 "pdf.php" 但它不工作。我检查了一些教程和视频,只是不明白它的错误。

任何 help/suggestion 将不胜感激

<?php
require('fpdf181/fpdf.php');

//defining pdf objectives
$pdf = new FPDF('p', 'mm', 'A4');

//Document properties
$pdf-> SetTitle('Auftrag Anbieterwechsel');

//SetFont
$pdf->SetFont('Helvetica','B',14);

$pdf->AddPage('P'); 
$pdf->SetDisplayMode('real','default');

$pdf->SetXY(50,20);
$pdf->SetDrawColor(50,60,100);
$pdf->Cell(100,10,'FPDF Tutorial',1,0,'C',0);

$pdf->SetXY(10,50);
$pdf->SetFontSize(10);
$pdf->Write(5,'Congratulations! You have generated a PDF. ');

$pdf->Output('MDDSL.pdf','I');
?>

现在显示输出 "The page isn't working"。

你的代码有一些错误。

1 - $pdf = SetTitle('Something');  --> $pdf->SetTitle('Something');

2 - $pdf->SetDisplayMode(real,'default'); --> $pdf->SetDisplayMode('real','default'); //because real is a string value and needs quote

另外请确保您通往 fpdf.php 的路径是正确的。否则代码对我有用。