I am trying to create an class object to a class but I keep getting some unknown error.
This is the "helper class" which it takes content from an XML file
<?php
class helperClass {
private $name;
private $weight;
private $category;
private $location;
//Creates a new product object with all its attributes
function __construct(){}
//List products from thedatabase
function listProduct(){
$xmlDoc = new DOMDocument();
$xmlDoc->load("storage.xml");
print $xmlDoc->saveXML();
}
?>
}
And here I am trying to create an object from the helperClassclass and call the method listProducts from helperClass, but the code it won't work if I try to instantiate an object of the helperClass
<?php
//Working code...
class businessLogic {
private $helper = null;
public function __construct() {
}
public function printXML() {
$obj = new helperClass();
$obj->fetchFromXMLDocument();
// you probably want to store that new object somewhere, maybe:
$this->helper = $obj;
}
}
}
?>
After the help of you guys I figured it out and this is what I wanted to do
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
require 'businessLogic.php';
$obj = new businessLogic();
$obj->printXML();
?>
</body>
</html>