久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='itrQo'><style id='itrQo'><dir id='itrQo'><q id='itrQo'></q></dir></style></legend>
    • <bdo id='itrQo'></bdo><ul id='itrQo'></ul>

      <tfoot id='itrQo'></tfoot>
    1. <small id='itrQo'></small><noframes id='itrQo'>

      <i id='itrQo'><tr id='itrQo'><dt id='itrQo'><q id='itrQo'><span id='itrQo'><b id='itrQo'><form id='itrQo'><ins id='itrQo'></ins><ul id='itrQo'></ul><sub id='itrQo'></sub></form><legend id='itrQo'></legend><bdo id='itrQo'><pre id='itrQo'><center id='itrQo'></center></pre></bdo></b><th id='itrQo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='itrQo'><tfoot id='itrQo'></tfoot><dl id='itrQo'><fieldset id='itrQo'></fieldset></dl></div>

        通過 id 查找元素并用 php 替換其內(nèi)容

        Find an element by id and replace its contents with php(通過 id 查找元素并用 php 替換其內(nèi)容)
      1. <small id='Ds13F'></small><noframes id='Ds13F'>

              • <legend id='Ds13F'><style id='Ds13F'><dir id='Ds13F'><q id='Ds13F'></q></dir></style></legend>
                <tfoot id='Ds13F'></tfoot>
                <i id='Ds13F'><tr id='Ds13F'><dt id='Ds13F'><q id='Ds13F'><span id='Ds13F'><b id='Ds13F'><form id='Ds13F'><ins id='Ds13F'></ins><ul id='Ds13F'></ul><sub id='Ds13F'></sub></form><legend id='Ds13F'></legend><bdo id='Ds13F'><pre id='Ds13F'><center id='Ds13F'></center></pre></bdo></b><th id='Ds13F'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ds13F'><tfoot id='Ds13F'></tfoot><dl id='Ds13F'><fieldset id='Ds13F'></fieldset></dl></div>
                  <bdo id='Ds13F'></bdo><ul id='Ds13F'></ul>

                    <tbody id='Ds13F'></tbody>
                • 本文介紹了通過 id 查找元素并用 php 替換其內(nèi)容的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我想使用 PHP 在文件內(nèi)容中搜索具有特定 ID 的元素,替換其內(nèi)容,然后將更改保存到文件中.我能夠加載 HTML,然后再次將其保存,但是在查找和替換"(目前正在嘗試使用 preg_replace)時(shí)遇到問題.

                  I want to use PHP to search through the contents of a file for an element with a specific id, replace its contents, then save my changes to the file. I'm able to load in the HTML, and save it back out again, but am having trouble with the 'find and replace' (currently trying to use preg_replace).

                  這是我目前所擁有的:

                  <?php
                  // read in the content
                  $file = file_get_contents('file.php');
                  
                  // parse $file, looking for the id.
                  $replace_with = "id='" . 'myID' . "'>" . $replacement_content . "<";
                  if ($updated = preg_replace('/id="myID">.*?</', $replace_with, $file)) {   
                      // write the contents of $file back to index.php, and then refresh the page.
                      file_put_contents('file.php', $updated);
                  }
                  

                  然而,雖然它成功加載內(nèi)容并將其寫出(我已經(jīng)通過寫入單獨(dú)的文件對(duì)其進(jìn)行了測試),但似乎 $updated 實(shí)際上并沒有改變.

                  However, while it successfully loads in the content and writes it out (I've tested it by writing to a separate file), it appears that $updated doesn't actually change.

                  有什么想法嗎?

                  推薦答案

                  你可以使用 PHP 的 DOMDocument 為此:

                  You can use PHP's DOMDocument for this:

                  $html = new DOMDocument(); 
                  $html->loadHTMLFile('file.php'); 
                  $html->getElementById('myId')->nodeValue = 'New value';
                  $html->saveHTMLFile("foo.html");
                  

                  這篇關(guān)于通過 id 查找元素并用 php 替換其內(nèi)容的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務(wù)器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機(jī))
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實(shí)現(xiàn))
                  Sending a byte array from PHP to WCF(將字節(jié)數(shù)組從 PHP 發(fā)送到 WCF)
                  <tfoot id='iRQA7'></tfoot>

                        <i id='iRQA7'><tr id='iRQA7'><dt id='iRQA7'><q id='iRQA7'><span id='iRQA7'><b id='iRQA7'><form id='iRQA7'><ins id='iRQA7'></ins><ul id='iRQA7'></ul><sub id='iRQA7'></sub></form><legend id='iRQA7'></legend><bdo id='iRQA7'><pre id='iRQA7'><center id='iRQA7'></center></pre></bdo></b><th id='iRQA7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iRQA7'><tfoot id='iRQA7'></tfoot><dl id='iRQA7'><fieldset id='iRQA7'></fieldset></dl></div>
                      1. <legend id='iRQA7'><style id='iRQA7'><dir id='iRQA7'><q id='iRQA7'></q></dir></style></legend>
                            <bdo id='iRQA7'></bdo><ul id='iRQA7'></ul>
                              <tbody id='iRQA7'></tbody>

                            <small id='iRQA7'></small><noframes id='iRQA7'>

                          • 主站蜘蛛池模板: 国产aⅴ爽av久久久久成人 | 视频一区二区三区在线观看 | 免费av网站在线观看 | 日韩精品在线免费观看 | 欧美成人激情视频 | 亚洲欧美日韩成人 | 亚洲最新网址 | 欧美日韩免费 | 日韩伦理一区 | 黄色一区二区三区 | 伦一理一级一a一片 | 日本理伦片午夜理伦片 | 日本a级大片 | 毛片毛片毛片毛片毛片 | 中文字幕在线观看第一页 | 成人一级毛片 | 黄色小视频免费看 | 思思在线视频 | 日日夜夜狠狠操 | 一级片久久 | 欧美日韩精品在线观看 | 青青操影院 | 欧美日韩性 | 天天曰天天干 | 欧美日韩第一区 | 日韩av资源 | 天天干网站 | 天堂资源av | 天天干天天干天天干 | 理论片中文字幕 | 久久国产精品一区二区三区 | 日韩免费三级 | 色婷婷av一区二区三区之e本道 | 亚洲深夜福利 | 免费观看一区二区三区毛片 | 免费精品视频 | 亚洲日本欧美 | 久热综合| 欧美xx孕妇 | 国产小视频在线播放 | 日韩免费大片 |