note 86861 added to function.simplexml-element-construct

From: Date: Thu, 06 Nov 2008 23:12:30 +0000
Subject: note 86861 added to function.simplexml-element-construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-146260@lists.php.net to get a copy of this message
Note to tudor: You can't override the constructor, but you can get around that with a simple static method: <?php class simpleXmlExtender extends SimpleXMLElement { public static function _new($xml=NULL, $ns=NULL, $prefix=TRUE) { // allows you to set certain option parameters to new default values, // or automatically decide whether input data is a file or not // optionally, you can save the object in an intermediate variable // and peform other actions on/with it before returning it return new simpleXmlExtender($xml, LIBXML_NOCDATA, file_exists($xml), $ns, $prefix); } } $simpleXML = simpleXmlExtender::_new($xmldata); ?> ... it's a bit of a hack, but it works. ---- Server IP: 209.41.74.194 Probable Submitter: 24.196.230.22 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-construct.php Edit -- https://master.php.net/note/edit/86861 Del: integrated -- https://master.php.net/note/delete/86861/integrated Del: useless -- https://master.php.net/note/delete/86861/useless Del: bad code -- https://master.php.net/note/delete/86861/bad+code Del: spam -- https://master.php.net/note/delete/86861/spam Del: non-english -- https://master.php.net/note/delete/86861/non-english Del: in docs -- https://master.php.net/note/delete/86861/in+docs Del: other reasons-- https://master.php.net/note/delete/86861 Reject -- https://master.php.net/note/reject/86861 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146260) next »