Jump to content

Recommended Posts

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]
<?php

ini_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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.