In what situations would it be more beneficial to generate a PDF file instead of a DOC file in PHP for document generation?
Generating a PDF file instead of a DOC file in PHP for document generation would be more beneficial when you want to ensure that the document layout and formatting remains consistent across different devices and platforms. PDF files are also more secure and harder to edit compared to DOC files. Additionally, PDF files are generally smaller in size and easier to share and distribute.
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output('output.pdf','F');
?>