stubrook Posted July 21, 2006 Share Posted July 21, 2006 Hello,I have the following code below and all im tyring to do is make use of a query string value inside a function in the class. The if statement im trying to use the query string value is shown below. Does anyone know how to acheive this?Many thanks[code]<?phpini_set("register_globals", "on");class RSSParser{ var $insideitem = false; var $tag = ""; var $title = ""; var $body = ""; function startElement($parser, $tagName, $attrs) { if ($this->insideitem) { $this->tag = $tagName; } elseif ($tagName == "ITEM") { $this->insideitem = true; } } function endElement($parser, $tagName) { if ($tagName == "ITEM") { printf("<b>%s</b></dt>", htmlspecialchars(trim($this->title))); printf("%s", htmlspecialchars(trim($this->body))); $this->title = ""; $this->body = ""; $this->insideitem = false; } } function characterData($parser, $data) { if ($this->insideitem) {[b] if ($lang == "en")[/b] { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "BODY": $this->body .= $data; break; } } } }}$xml_parser = xml_parser_create();$rss_parser = new RSSParser();xml_set_object($xml_parser,&$rss_parser);xml_set_element_handler($xml_parser, "startElement", "endElement");xml_set_character_data_handler($xml_parser, "characterData");$fp = fopen("rss.txt","r") or die("Error reading RSS data.");while ($data = fread($fp, 4096)) xml_parse($xml_parser, $data, feof($fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));fclose($fp);xml_parser_free($xml_parser);?>[/code] Link to comment https://forums.phpfreaks.com/topic/15258-beginer-use-query-string-in-a-class/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.