0

I have the file code.php in the js folder of my Cakephp.

I also have the file resultcontroller in the folder src/controller/resultcontroller.php

Inside my code.php file:

<?php
$dom = new DOMDocument('1.0');
...
?>

Inside my controller:

namespace App\Controller;
...
Class ResultController extendes Controller{
...
public function littlebutton()
    {
        $doc = new DOMDocument();
    ...
    }
...

When i run the app, if i call the function littlebutton it give me the error: ERROR:Class App/Controller/DOMDocument not found. When i run the app and call the code.php file (which is called with an ajax call) it works fine.

I have 2 doubts.

One is why it works with one file and doesn't work with the other? I don't do any call to any class in my code.php file and it works so i expected to do so in the controller.

Second, i read that DOMDocument is included in the php and i dont need to do anything to make it work. And now i don't know.

Please could someone give me some advise? Thank you.

Sandra G.
  • 119
  • 3
  • 16
  • 2
    Namespace. Use `new \DOMDocument()` (backslash at front) http://www.php.net/manual/en/language.namespaces.rationale.php – ficuscr Sep 13 '17 at 18:08
  • I wrote $dom=new \DOMDocument(); and now it gives me several warnings that look almost the same as: Warning (2): DOMDocument::loadHTML() [domdocument.loadhtml]: Tag svg invalid in Entity, line: 89 [APP/Controller\ResultController.php, line 11696] – Sandra G. Sep 13 '17 at 18:13
  • Totally separate issue... First solved, now read: https://stackoverflow.com/questions/6090667/php-domdocument-errors-warnings-on-html5-tags – ficuscr Sep 13 '17 at 18:15

0 Answers0