با سلام
namespace Exporter;
require_once "./vendor/autoload.php";
class PdfExporter extends Exporter
{
protected $format = '.pdf';
protected $pdfclass;
public function __construct($pdfclass)
{
$this->pdfclass = $pdfclass;
}
public function export()
{
$file_name = 'text-file-' . rand(100,999) . $this->format;
$file_path = __DIR__ . "/files/$file_name";
$this->pdfclass->WriteHTML("{$this->data['title']},{$this->data['content']}");
$this->pdfclass->Output($file_path);
echo "$file_name successfully created!";
}
}
$pdfExporter = new PdfExporter(new \\Mpdf\\Mpdf());
$pdfExporter->export();
این کد PdfExporter منه وقتی اجرا میکنم فایل pdf ساخته میشه منتهی یه خطایی هم میده
Warning: Trying to access array offset on value of type null in C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\Exporter\\PdfExporter.php on line 21
Warning: Trying to access array offset on value of type null in C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\Exporter\\PdfExporter.php on line 21
text-file-869.pdf successfully created!
Fatal error: Uncaught Error: Call to a member function WriteHTML() on array in C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\Exporter\\PdfExporter.php:21 Stack trace: #0 C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\process.php(21): Exporter\\PdfExporter->export() #1 C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\index.php(1): include('C:\\\\xampp\\\\htdocs...') #2 {main} thrown in C:\\xampp\\htdocs\\7Learn.php\\OOP\\Project-Exporter\\Exporter\\PdfExporter.php on line 21
این هم متن خطا ممنون میشم راهنمایی کنید.