PHP nesne özelliği beyanı hata

0 Cevap

Ben yaratıyorum bir PHP sınıfı bir özelliği tanımlayan biraz sorun yaşıyorum.

<?php
class news_parser {
    public $var1 = Array();
    function contents($parser, $data) {
        printf($data);
    }
    function start_tag($parser, $data, $attribs) {
        printf($data);
    }
    function end_tag($parser, $data) {
        printf($data);
    }
    function parse() {
        if(!$file = fopen("http://services.digg.com/2.0/story.getTopNews?type=rss&topic=technology", "r"))
            die("Error opening file");
        $data = fread($file, 80000);

        $xml_parser = xml_parser_create();
        xml_set_element_handler($xml_parser, array($this, "start_tag"), array($this, "end_tag"));
        xml_set_character_data_handler($xml_parser, array($this, "contents"));
        if(!xml_parse($xml_parser, $data, feof($fh)))
            die("Error on line " . xml_get_current_line_number($xml_parser));
        xml_parser_free($xml_parser);
        fclose($fh);
    }
}

$digg_parser = new news_parser();
$digg_parser->parse();
echo phpversion();

?>

Aşağıdaki hata üretir:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/8/d335242830/htdocs/caseyflynn/php/display_formatted_RSS_feed.php on line 3

Bildiğim kadarıyla söyleyebilirim ben doğru sözdizimi vardır. Benim sunucu PHP 4.5 çalışıyor. Herhangi bir fikir?

0 Cevap