Saturday 12 July 2014

Strict Standards: Non-static method DOMDocument::load() should not be called statically - PHP 0

In PHP recently I faced this issue. When I tried to use my xml file using php's document load() function.

Problem
$dom = DOMDocument::load('myXml.xml');
It works perfectly. But I throws error
Strict Standards: Non-static method DOMDocument::load() should not be called statically
Solution
The reason why it's happening is because I called a load() method in the DOMDocument class in which is not static.

 Instead of calling it with :: We need to call it with ->

I found PHP document about the usage of DOMDocument load() method.
$doc = new DOMDocument();
$doc->load('myXml.xml');
Now the error is gone...!!!

Have any doubt feel free to comment here!


0 comments:

Post a Comment