<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                這些函數/常量從PHP 5.1.0開始可用,以下核心擴展依賴于此libxml擴展:[DOM](https://www.php.net/manual/en/book.dom.php),[libxml](https://www.php.net/manual/en/book.libxml.php),[SimpleXML](https://www.php.net/manual/en/book.simplexml.php),[SOAP](https://www.php.net/manual/en/book.soap.php),[WDDX](https://www.php.net/manual/en/book.wddx.php),[XSL](https://www.php.net/manual/en/book.xsl.php),[XML](https://www.php.net/manual/en/book.xml.php),[XMLReader](https://www.php.net/manual/en/book.xmlreader.php),[XMLRPC](https://www.php.net/manual/en/book.xmlrpc.php)和[XMLWriter](https://www.php.net/manual/en/book.xmlwriter.php) * [預定義常量](https://www.php.net/manual/en/libxml.constants.php) * [libXMLError](https://www.php.net/manual/en/class.libxmlerror.php)— libXMLError類 ## [**libxml函數**](https://www.php.net/manual/en/ref.libxml.php) 1、[libxml\_clear\_errors( void ) : void](https://www.php.net/manual/en/function.libxml-clear-errors.php)—清除libxml錯誤緩沖區 2、[libxml\_disable\_entity\_loader([ bool $disable = TRUE ] ) : bool](https://www.php.net/manual/en/function.libxml-disable-entity-loader.php)—禁用加載外部實體的功能,使用此功能可以防止本地和遠程文件包含攻擊(,這還會禁用simplexml_load_file()中的url加載,并可能禁用處理URL的其他基于libxml的函數;此函數不是線程安全的。 因此,這可能會影響同一服務器上的php腳本) ``` 文件包含例子 <!DOCTYPE scan [<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=/etc/passwd">]> <scan>&test;</scan> ``` 3、[libxml\_get\_errors( void ) : array](https://www.php.net/manual/en/function.libxml-get-errors.php)—檢索錯誤數組 此示例演示如何構建簡單的libxml錯誤處理程序。 ``` libxml_use_internal_errors(true); $xmlstr = <<< XML <?xml version='1.0' standalone='yes'?> <movies> <movie> <titles>PHP: Behind the Parser</title> </movie> </movies> XML; $doc = simplexml_load_string($xmlstr); $xml = explode("\n", $xmlstr); if ($doc === false) { $errors = libxml_get_errors(); foreach ($errors as $error) { echo display_xml_error($error, $xml); } libxml_clear_errors(); } function display_xml_error($error, $xml) { $return = $xml[$error->line - 1] . "\n"; $return .= str_repeat('-', $error->column) . "^\n"; switch ($error->level) { case LIBXML_ERR_WARNING: $return .= "Warning $error->code: "; break; case LIBXML_ERR_ERROR: $return .= "Error $error->code: "; break; case LIBXML_ERR_FATAL: $return .= "Fatal Error $error->code: "; break; } $return .= trim($error->message) . "\n Line: $error->line" . "\n Column: $error->column"; if ($error->file) { $return .= "\n File: $error->file"; } return "$return\n\n--------------------------------------------\n\n"; } ``` 輸出 ``` <titles>PHP: Behind the Parser</title> ----------------------------------------------^ Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title Line: 4 Column: 46 -------------------------------------------- ``` 4、[libxml\_get\_last\_error(void):LibXMLError](https://www.php.net/manual/en/function.libxml-get-last-error.php)—從libxml檢索最后一個錯誤 5、 [libxml\_set\_external\_entity\_loader](https://www.php.net/manual/en/function.libxml-set-external-entity-loader.php)—更改默認的外部實體加載器 ``` $xml = <<<XML <!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar"> <foo>bar</foo> XML; $dtd = <<<DTD <!ELEMENT foo (#PCDATA)> DTD; libxml_set_external_entity_loader( function ($public, $system, $context) use($dtd) { var_dump($public); var_dump($system); var_dump($context); $f = fopen("php://temp", "r+"); fwrite($f, $dtd); rewind($f); return $f; } ); $dd = new DOMDocument; $r = $dd->loadXML($xml); var_dump($dd->validate()); ``` 返回值: ``` string(10) "-//FOO/BAR" string(25) "http://example.com/foobar" array(4) { ["directory"] => NULL ["intSubName"] => NULL ["extSubURI"] => NULL ["extSubSystem"] => NULL } bool(true) ``` 6、 [libxml\_set\_streams\_context](https://www.php.net/manual/en/function.libxml-set-streams-context.php)—設置下一個libxml文檔加載或寫入的流上下文 ``` $opts = array( 'http' => array( 'user_agent' => 'PHP libxml agent', ) ); $context = stream_context_create($opts); libxml_set_streams_context($context); // request a file through HTTP $doc = DOMDocument::load('http://www.example.com/file.xml'); ``` 7、[libxml\_use\_internal\_errors](https://www.php.net/manual/en/function.libxml-use-internal-errors.php)—禁用libxml錯誤,并允許用戶根據需要獲取錯誤信息 ``` //此示例演示libxml錯誤的基本用法以及此函數返回的值。 //?啟用用戶自定義錯誤處理 var_dump(libxml_use_internal_errors(true)); //?開始加載文件 $doc?=?new?DOMDocument; if?(!$doc->load('file.xml'))?{ ????foreach?(libxml_get_errors()?as?$error)?{ ????????//?在這處理接受到的錯誤 ????} ????libxml_clear_errors(); } ``` The above example will output: ~~~ bool(false) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看