/**
* DOMXML function notes
* After connecting php_domxml.dll
* Use get_defined_functions() to get domxml support functions
*
* Currently domxml does not support language declarations other than iso-8859-1
* Supported
* Not supported
* Therefore, it needs to be transformed into this, which may require
* utf8_encode() utf8_decode() functions for processing
*
* function list
* string domxml_version(void) Returns the version number of domxml
* object xmldoc(string str) Creates an XML Domdocument object from a string
* object xmldocfile(string filename) Creates an XML Domdocument object from a file
* object xmltree(string str) Parses the xml document and returns the tree structure, which cannot be changed with the domxml function XML string. There is a problem with this function. It will add an extended ascii character in front of the first Chinese character, in the form of nnn;
* domxml_node_attributes
* domxml_elem_get_attribute
* domxml_elem_set_attribute
* array domxml_node_children(object doc |node) Return child node
* domxml_node_new_child
* object domxml_node(string name) Create a node node
* domxml_node_unlink_node
* int domxml_node_set_content(resource doc,string content) Set node content
* object domxml_new_xmldoc(string version) Create a new empty XML object
* xpath_new_context
* xpath_eval
* xpath_eval_expression
* xptr_new_context
* xptr_eval
* object domxml_root(object doc) Return the root node
* array domxml_attributes(resource note) Get node attributes
* object domxml_get_attribute(resource doc,string name) Read attributes
* domxml_getattr
* object domxml_set_attribute(resource doc,string name,string value) Add attribute
* domxml_setattr
* array domxml_children(object doc|node) Return child node
* resource domxml_new_child(string name,string content) Add child node
* domxml_unlink_node
* set_content
* new_xmldoc
*
*/
?>
<br><?php <br>// Document xml source tree.xml content<br> $testxml = '<br><?xml version="1.0" encoding="GB2312"?> <br><root><br><note>When reading the xml document, the processor will form a tree , we call it the source tree. The tree has various types of nodes in the table. <br></note><br><title>The source tree has node</title> <br><table> <br><tr> <th>Node type</th> <th>Description</th> </tr> <br><tr> <td>Root (root)</td> <td>This is the root node of the tree. Can appear anywhere on the tree. The root node has only one child node, and the child node refers to the document element node in the xml document. </td> </tr> <br><tr> <td>Element (element)</td> <td>This node is used for any element in the document. The child nodes of an element node can be element nodes, annotation nodes, processing information nodes, and text nodes of its content. </td> </tr> <br><tr> <td>Text(text)</td> <td>All text appearing in the document are grouped into text nodes. A text node cannot have any immediately preceding or following sibling nodes that are also text nodes. </td> </tr> <br><tr> <td>Attribute (attribute)</td> <td>Each element node has its own set of attached attribute nodes. Default property values are handled in the same way as specified properties. None of these nodes have child nodes. </td> </tr> <br><tr> <td>Namespace(name)</td> <td>For every element starting with xlmns: and an attribute node, there is a Name space node. These nodes have no child nodes. </td> </tr> <br><tr> <td>Processing Instruction(processing instruction)</td> <td>Each processing instruction has a separate node. None of these nodes have child nodes. </td> </tr> <br><tr> <td>Comment (Comment)</td> <td>Each has a comment node. None of these nodes have child nodes.</td> </tr> <br> </table> <br></root><br>';<br><br>echo "domxml version:".domxml_version();<br>echo "<p> </p>";<br>// xmltree domxml_dumpmem<br>$filename = "xml source tree.xml";<br>//$filename = "resume.xml";<br>$fp = fopen($filename,"r"); <br>$inXML = fread($fp,filesize($filename)); <br>fclose($fp); <br>// Delete language setting Define<br>//$inXML = str_replace(' encoding="GB2312"',"",$inXML);<br>$inXML = eregi_replace(' encoding="[a-z0-9_-]+"', "",$inXML);<br><br>$doc = xmltree($inXML); // Use xmltree to parse <br>$myxml = $doc->dumpmem(); // Convert to string, header For xml version = "1.0" <br> // If you execute it again, your head will become xml version = "1.0" encoding = "ISO-8859-1" <br> // $ Myxml = EREGI_REPLE ('[[[' [[ 0-9]+;',"",$myxml); // Delete<br>echo "Use xmltree to parse<br>";<br>echo "<textarea cols="60" rows="5">$myxml<br>";<br>//print_r($doc); // You can see the entire tree or use var_dump($doc);<br><br>// xmldoc<br>$doc = xmldoc($inXML); <br>$myxml = $doc->dumpmem();<br>echo "Use xmldoc to parse<br>";<br>echo "<textarea cols="60" rows="5"> $myxml</textarea><br>";<br>//print_r($doc); // Only the root node can be seen<br><br>// domxml_new_xmldoc<br>$doc = domxml_new_xmldoc("1.0 ");<br><br>$root = $doc->add_root("HTML");<br>$head = $root->new_child("HEAD", "");<br>$head ->new_child("TITLE", "DOMXML Test 0");<br>$head->new_child("TITLE", "DOMXML Test 1");<br>$head->set_attribute("Language" , "ge");<br>domxml_node_set_content($head,"ppp"); // Set the content of the node, multiple executions are superimposed<br>domxml_node_set_content($head,"ttt");<br><br>// It is a function with only 1-2 "_" in the function name, which can be used as an object method <br><br>$myxml = $doc->dumpmem();<br>echo "custom xml<br>";<br>echo "<textarea cols="60" rows="5">$myxml</textarea><br>";<br><br>// Traversal of nodes<br>/** <br> Node Structure<br> DomElement Object<br> type = 1<br> tagname = Node Name<br> DomText Object<br> type = 3<br> content = Section Content Point<br> DomCData Object<br> type = 4<br> content = section content point<br><br> DomProcessingInstruction Object<br> type none<br> target = processing instruction<br> data = parameter<br><br>*/<br>$ar[] = $doc->root(); // Get the root node <br>$ar[] = $ar[count($ar)-1]->children ();<br>$ar[] = $ar[count($ar)-1][0]->children();<br><br>// Function domxml_children() cannot return node parameters<br>//To return node parameters, you need to use domxml_attributes()<br>//var_dump(domxml_attributes($head));<br>//print_r($ar[1][0]->attributes());<br>//print_r($ar);<br><br>function xml_dumpmem($xmldoc) {<br> static $mode = 0;<br> $xmlstr = "";<br> // Get the node and save it in In the array<br> if(get_class($xmldoc) == "DomDocument") {<br> $xmlstr = '<?xml version="1.0" encoding="gb2312"?>'."n";<br> if(count($xmldoc->children) == 1) // Root node, no other members <br> $docs[] = $xmldoc->root();<br> else<br> $ docs = $xmldoc->children(); // Root node, with other members <br> }else {<br> $docs = $xmldoc->children(); // General node <br> }<br><br>// echo __LINE__."<br>";<br> foreach($docs as $doc) {<br> $attr = $doc->attributes();<br> switch($doc ->type) {<br> case 1:<br> $xmlstr .= "tagname}"; // Tag header<br> if($attr) {<br> foreach( $attr as $key)<br> $xmlstr<br> $xmlstr .= ">"; // End of tag <br> $xmlstr .= xml_dumpmem($doc); // Enter child node <br> $xmlstr .= "{$doc-> ;tagname}>"; // Close tag<br> break;<br> case 3:<br> $xmlstr .= $doc->content;<br> case 4:<br> $xmlstr .= " $xmlstr default:<br> if(get_class($doc) == "DomProcessingInstruction") {<br> $xmlstr .= "{$doc->target}";<br> $xmlstr .= " {$ doc->data}?>n";<br> }<br> break;<br> }<br> }<br> return $xmlstr;<br>}<br><br>if(1) {<br> $filename = "resume.xml";<br>// $filename = "resume.xsl";<br> $filename = "xml source tree.xml";<br> $fp = fopen($ filename,"r"); <br> $inXML = fread($fp,filesize($filename)); <br> fclose($fp); <br> $inXML = eregi_replace(' encoding="[a-z0 -9_-]+"',"",$inXML);<br>// $doc = xmltree($inXML); // Use xmltree to parse <br> $doc = xmldoc($inXML); // Use xmldoc Parse<br>}<br><br>// Cannot be used to parse xsl documents<br><br>$myxml = xml_dumpmem($doc);<br>echo "Write your own dumpmem and you won’t go wrong<br>echo "<textarea cols="60" rows="5">$myxml</textarea><br>";<br>print_r($doc);<br><br>?><br></textarea>
http://www.bkjia.com/PHPjc/313922.html
www.bkjia.com

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools
