PHP 8.5.0 Alpha 1 available for testing

Voting

: six minus six?
(Example: nine)

The Note You're Voting On

darien at etelos dot com
18 years ago
This documentation is somewhat awry. I know it's been said many times before, but it bears repeating...

If using PHP4, you may be required to use xml_set_object() instead of calling any of the xml_set_*_handler() functions with a two-item array. It will work fine on PHP5, but move the same code to PHP4 and it will create one copie of $this (even if you use &$this) for each handler you set!

<?php
// This code will fail mysteriously on PHP4.
$this->parser = xml_parser_create();
xml_set_element_handler(
$this->parser,
array(&
$this,"start_tag"),
array(&
$this,"end_tag")
);
xml_set_character_data_handler(
$this->parser,
array(&
$this,"tag_data")
);
?>

<?php
// This code will work on PHP4.
$this->parser = xml_parser_create();
xml_set_object($this->parser,&$this);
xml_set_element_handler(
$this->parser,
"start_tag",
"end_tag"
);
xml_set_character_data_handler(
$this->parser,
"tag_data"
);
?>

<< Back to user notes page

To Top