RE: [PHP] Confused About Classes

2002-03-25 Thread Rick Emery

However, startElementHandler() is not be called in a class context.
According to the manual for xml_set_element_handler():
"There is currently no support for object/method handlers."


-Original Message-
From: arti [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 9:43 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Confused About Classes


No, the only thing I supplied is the class.  The startElementHandler IS a
function in the class.



"Rick Emery" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >  if ($this->private==FALSE) //  <<<< Undefined variable
> this
> >  return;
> > }
>
> $this is relevant ONLY within the scope of the class definition.
> The above snippet is located OUTSIDE of the class definition.
> You must use an object pointer.  That is:
>
> $newobj = new standardquestion($filename);
> if( $newobj->private==FALSE)
> {
> }
> -Original Message-
> From: arti [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 9:33 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Confused About Classes
>
>
> I am getting the error "Undefined variable this" in my class.  I am new to
> PHP and presume I am just doing something wrong.  But, I don't understand
> what it could be as the code looks straightforward to me.  Note that I
> trimmed out some code to keep this listing from being huge, but the
relevant
> pieces are included.
>
>
> 
> class standardquestion
> {
>
> var $private;
>
> function standardquestion($xmlfilename)
> {
>
>  $this->private=FALSE;
>
>  $parser=xml_parser_create();
>
>  xml_set_element_handler($parser,
> array("standardquestion","startElementHandler"),
> array("standardquestion","endElementHandler"));
>
>  while ($data = fread($fp, 4096))
>  {
>   if (!xml_parse($parser, $data, feof($fp)))
>   {
>die(sprintf("XML error %d %d",
> xml_get_currentnode_line_number($parser),
> xml_get_currentnode_column_number($parser)));
>   }
>  }
> }
>
> function startElementHandler($parser, $name, $attribs)
> {
>  if ($name=="private")
>   $this->private = TRUE;
>
>  if ($this->private==FALSE) //  <<<< Undefined variable
this
>   return;
> }
>
>
> function endElementHandler($parser, $name)
> {
> }
>
>
> }
> ?>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Confused About Classes

2002-03-25 Thread arti

No, the only thing I supplied is the class.  The startElementHandler IS a
function in the class.



"Rick Emery" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >  if ($this->private==FALSE) //   Undefined variable
> this
> >  return;
> > }
>
> $this is relevant ONLY within the scope of the class definition.
> The above snippet is located OUTSIDE of the class definition.
> You must use an object pointer.  That is:
>
> $newobj = new standardquestion($filename);
> if( $newobj->private==FALSE)
> {
> }
> -Original Message-
> From: arti [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 9:33 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Confused About Classes
>
>
> I am getting the error "Undefined variable this" in my class.  I am new to
> PHP and presume I am just doing something wrong.  But, I don't understand
> what it could be as the code looks straightforward to me.  Note that I
> trimmed out some code to keep this listing from being huge, but the
relevant
> pieces are included.
>
>
> 
> class standardquestion
> {
>
> var $private;
>
> function standardquestion($xmlfilename)
> {
>
>  $this->private=FALSE;
>
>  $parser=xml_parser_create();
>
>  xml_set_element_handler($parser,
> array("standardquestion","startElementHandler"),
> array("standardquestion","endElementHandler"));
>
>  while ($data = fread($fp, 4096))
>  {
>   if (!xml_parse($parser, $data, feof($fp)))
>   {
>die(sprintf("XML error %d %d",
> xml_get_currentnode_line_number($parser),
> xml_get_currentnode_column_number($parser)));
>   }
>  }
> }
>
> function startElementHandler($parser, $name, $attribs)
> {
>  if ($name=="private")
>   $this->private = TRUE;
>
>  if ($this->private==FALSE) //   Undefined variable
this
>   return;
> }
>
>
> function endElementHandler($parser, $name)
> {
> }
>
>
> }
> ?>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Confused About Classes

2002-03-25 Thread Rick Emery

>  if ($this->private==FALSE) //   Undefined variable
this
>  return;
> }

$this is relevant ONLY within the scope of the class definition.
The above snippet is located OUTSIDE of the class definition.
You must use an object pointer.  That is:

$newobj = new standardquestion($filename);
if( $newobj->private==FALSE)
{
}
-Original Message-
From: arti [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 9:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Confused About Classes


I am getting the error "Undefined variable this" in my class.  I am new to
PHP and presume I am just doing something wrong.  But, I don't understand
what it could be as the code looks straightforward to me.  Note that I
trimmed out some code to keep this listing from being huge, but the relevant
pieces are included.


private=FALSE;

 $parser=xml_parser_create();

 xml_set_element_handler($parser,
array("standardquestion","startElementHandler"),
array("standardquestion","endElementHandler"));

 while ($data = fread($fp, 4096))
 {
  if (!xml_parse($parser, $data, feof($fp)))
  {
   die(sprintf("XML error %d %d",
xml_get_currentnode_line_number($parser),
xml_get_currentnode_column_number($parser)));
  }
 }
}

function startElementHandler($parser, $name, $attribs)
{
 if ($name=="private")
  $this->private = TRUE;

 if ($this->private==FALSE) //   Undefined variable this
  return;
}


function endElementHandler($parser, $name)
{
}


}
?>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php