久久久久久久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'>

                          • 主站蜘蛛池模板: 91观看| 一区二区亚洲 | 精品久久一区二区三区 | 国产精品一区二区在线免费观看 | 国产视频一视频二 | 欧美成ee人免费视频 | 国产精久久久 | 黄色免费在线网址 | 在线看av网址 | 99精品视频一区二区三区 | www.精品国产 | 日本精品裸体写真集在线观看 | 人人操日日干 | 亚洲精品一区二区久 | 天天综合天天 | 中文字幕av色 | 国产一区二区三区四区五区加勒比 | 欧美一区成人 | 成人精品一区二区三区中文字幕 | 精品国产三级 | 91久久视频 | 在线播放国产一区二区三区 | 成人妇女免费播放久久久 | 中国一级大黄大片 | 午夜电影日韩 | 久草网址 | 成年人在线视频 | 亚州av在线 | 久久极品 | 成人在线电影网站 | 深夜福利影院 | 国产欧美一区二区三区在线看 | 精品91久久 | 国产三区视频在线观看 | 99热都是精品 | 91免费在线视频 | 国产精品一区二区免费看 | 久久久久久国产精品三区 | 国产精品精品3d动漫 | 久久美女视频 | 男人的天堂久久 |