DEPRECATED CALL-TIME PASS-BY-REFERENCE IN PHP
A warning has been encountered regarding call-time pass-by-reference, which has been deprecated. This means that the following lines of code are causing the warning:
function XML() { $this->parser = &xml_parser_create(); xml_parser_set_option(&$this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_object(&$this->parser, &$this); xml_set_element_handler(&$this->parser, 'open','close'); xml_set_character_data_handler(&$this->parser, 'data'); }
Explanation of the Deprecation
Call-time pass-by-reference allows simulating the behavior of passing arguments by reference when they are passed by value. However, this is no longer necessary or recommended.
Additionally, passing objects by reference is also no longer necessary as objects are always modified when passed to functions.
How to Fix the Warning
To resolve the warning, simply remove the & symbols from the variable references. The code should be modified as follows:
function XML() { $this->parser = xml_parser_create(); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, 'open','close'); xml_set_character_data_handler($this->parser, 'data'); }
The above is the detailed content of How to Fix PHP\'s Deprecated Call-Time Pass-by-Reference Warning?. For more information, please follow other related articles on the PHP Chinese website!