PHP 8.5.0 Alpha 1 available for testing

Voting

: one plus three?
(Example: nine)

The Note You're Voting On

jhill at live dot com
16 years ago
To detect that concatenation of data is taking place, you can keep track of whether the last function call was to the data processing function.
e.g. using $this->inside_data variable below:

<?php
xml_set_element_handler
($this->parser, "start_tag", "end_tag");
xml_set_character_data_handler($this->parser, "contents");

protected function
contents($parser, $data)
{
switch (
$this->current_tag) {
case
"name":
if (
$this->inside_data)
$this->name .= $data; // need to concatenate data
else
$this->name = $data;
break;
...
}
$this->inside_data = true;
}

protected function
start_tag($parser, $name)
{
$this->current_tag = $name;
$this->inside_data = false;
}

protected function
end_tag() {
$this->current_tag = '';
$this->inside_data = false;
}
?>

<< Back to user notes page

To Top