note 92963 modified in function.simplexml-element-construct by danbrown

From: Date: Wed, 16 Sep 2009 15:45:34 +0000
Subject: note 92963 modified in function.simplexml-element-construct by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160661@lists.php.net to get a copy of this message
As I was filling out a bug report, I realized why (speculation here) the constructor is final: so that functions like simplexml_load_file and simplexml_load_string can work. I imagine the PHP-ized code looks something like <?php function simplexml_load_file($filename, $class_name = "SimpleXMLElement", $options = 0, $ns = "", $is_prefix = false) { return new $class_name($filename, $options, true, $ns, $is_prefix); } ?> If we were to use a different $class_name and change the constructor's definition these functions wouldn't work. There's no easy, sensible solution that keeps simplexml_load_file and simplexml_load_string. --was-- As I was filling out a bug report, I realized why (speculation here) the constructor is final: so that functions like simplexml_load_file and simplexml_load_string can work. I imagine the PHP-ized code looks something like <?php function simplexml_load_file($filename, $class_name = "SimpleXMLElement", $options = 0, $ns = "", $is_prefix = false) { return new $class_name($filename, $options, true, $ns, $is_prefix); } ?> If we were to use a different $class_name and change the constructor's definition these functions wouldn't work. There's no easy, sensible solution that keeps simplexml_load_file and simplexml_load_string. http://php.net/manual/en/function.simplexml-element-construct.php

« previous php.notes (#160661) next »