Unable to instantiate DOMDocument object inside Model class |
Hello.
Below is my model. (please take a look at $dom) PHP Code: <?php namespace App\Models; I cannot instantiate DOMDocument. Error logs showed this: CRITICAL - 2023-08-11 11:05:10 --> Class 'App\Models\DOMDocument' not found As if it thinks I'm referencing a model. But when I do the same on View files, it has no problem. (08-10-2023, 08:14 PM)mshahrim Wrote: Hello. Okay, I have found the solution. Since I need to instantiate DOMDocument, the PHP built-in objects, all I need to do is just add this declaration: PHP Code: use DOMDocument;
Heh, its base syntax - new \DOMDocument or use DOMDocument
Simple CI 4 project for beginners codeigniter-expenses
Try putting a slash in front of it like below, if that does not work it could be that the html DOM is not installed
in your php version. PHP Code: $dom = new \DOMDocument(); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
As you've found out, add a use statement at the top of the file:use DOMDocument;
This allows you to instantiate the DOMDocument class without the leading backslash in the rest of your file: $dom = new DOMDocument();
Shortcode Κατασκευή Eshop + Δημιουργία Ιστοσελίδων
Athens Greece |
Welcome Guest, Not a member yet? Register Sign In |