Home » XML » XML_Tree » Bug #4251
Using $this when not in object context
Details
| Submitted | 2005-05-01 01:02 UTC |
|---|---|
| From | abb644-spam at yahoo dot com |
| Status | Bogus |
| Package | XML_Tree |
| PHP Version | 5.0.3 |
| OS | Debian Woody |
| Roadmaps | (Not assigned) |
Comments
[2005-05-01 01:02 UTC] abb644-spam at yahoo dot com
Description:
------------
Fatal error: Using $this when not in object context in /usr/local/lib/php/XML/Tree.php on line 234
using XML_Tree-2.0.0RC2
Reproduce code:
---------------
<?
require_once('XML/Tree.php');
$xt = XML_Tree::getTreeFromFile('data.xml');
if (PEAR::isError($xt)){
echo "ERROR: When loading XML File.";
return;
}
echo "OK.\n";
$xt->dump();
?>
Expected result:
----------------
OK.
<dump of data.xml>
or
PEAR_Error
Actual result:
--------------
Fatal error: Using $this when not in object context in /usr/local/lib/php/XML/Tree.php on line 234
[2005-05-02 16:26 UTC] aaron dot hawley at uvm dot edu
The documentation says the function cannot be called statically. That is the error you should see because of that specification (I'm suprised PHP let you give the function an argument at all). Try instead:
$xt = new XML_Tree('data.xml');
$tree = $ft->getTreeFromFile();
if (XML_Tree::isError($tree)) {
...
[2005-05-02 17:42 UTC] abb644-spam at yahoo dot com
Is true, this is not a bug. Thanks.
The correct code to do this is:
<?
require_once('XML/Tree.php');
$xt = new XML_Tree('data.xml');
$res = $xt->getTreeFromFile();
if (PEAR::isError($res)){
echo "ERROR: When loading XML File.";
return;
}
echo "OK.\n";
$xt->dump();
?>