Can PHP be used to create *.doc or *.pdf files?
Yes, PHP can be used to create both *.doc and *.pdf files. To create a *.doc file, you can use PHP to generate HTML content and save it as a *.doc file. For creating a *.pdf file, you can use libraries like TCPDF or FPDF to generate PDF files from scratch or convert HTML content into PDF.
// Example to create a *.doc file
$htmlContent = "<html><body><h1>Hello, World!</h1></body></html>";
$file = 'example.doc';
file_put_contents($file, $htmlContent);
// Example to create a *.pdf file using TCPDF
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->writeHTML('<h1>Hello, World!</h1>');
$pdf->Output('example.pdf', 'F');