Я пытаюсь создать объект класса для класса, но получаю неизвестную ошибку.
Это "helper class
", который берет содержимое из XML
файла
<?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();
}
?>
}
И здесь я пытаюсь создать объект из helperClassclass
и вызвать метод listProducts
из helperClass
, но код не будет работать, если я попытаюсь создать экземпляр объекта 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;
}
}
}
?>
После помощи вас, ребята, я понял это, и это то, что я хотел сделать
<!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>