php class как реализовать ?!?!Вот на такую реализацию класса сразу ругается с момента присвоения переменной значения $this->xml_string = '<?xml version="1.0" encoding="UTF-8"?>'."
".'<aboutus>'."
"; Пишет Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION Помогите где не правильно написал, первый раз пытаюсь с классами работать :)
class write_xml{
public $filehandle;
public $filename;
public $xml_string;
$this->xml_string = '<?xml version="1.0" encoding="UTF-8"?>'."
".'<aboutus>'."
";
$this->filename = '/data/company.xml';
$this->filehandle = fopen($this->filename, 'w');
function getTrades(){
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__trades";
$db->setQuery($query);
$row = $db->loadAssocList();
return $row;
}
function getItems($division){
$row = $this->getTrades();
foreach ($row as $key => $value){
if ($value['parent'] == $division){
$items = $value['id'];
}
return $items;
}
}
function write{
fwrite($this->filehandle, $this->xml_string);
fclose($this->filehandle);
}
function getInfo(){
$trades = $this->getTrades();
$items = $this->getItems(0);
foreach ($items as $key_items => $value_items){
$id = $value_items;
foreach ($trades as $key_trades => $value_trades){
if ($id == $value_trades['parent']){
$company_image = $value_trades['display'];
$company_text_row = $value_trades['description'];
$company_text_splited = split ('[</p>]', $company_text_row);
foreach ($company_text_splited as $key => $value){
$company_text_ready[] = strip_tags($value);
}
$this->$xml_string .='<about opt="true" image="'.$company_image.'">'."
";
if ($company_text_ready){
foreach ($company_text_ready as $key => $value){
$this->xml_string .= $value;
}
}
$this->xml_string .='</about>'."
";
}
}
}
$this->xml_string .='</aboutus>';
$this->write();
}
}