久久久久久久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 替換其內容

        Find an element by id and replace its contents with php(通過 id 查找元素并用 php 替換其內容)
      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 替換其內容的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

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

                  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);
                  }
                  

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

                  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");
                  

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

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

                  相關文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機)
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實現)
                  Sending a byte array from PHP to WCF(將字節數組從 PHP 發送到 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久久精品一区二区二区 | 91久久精品日日躁夜夜躁国产 | 一区二区三区四区av | 青草久久免费视频 | 成人在线观看网站 | 亚洲精品888 | 日韩在线不卡 | 国产一区二区黑人欧美xxxx | 欧美九九九 | 国产精品自产拍 | 国产一二三区免费视频 | 国产精品99久久久久久宅男 | 亚洲精品视频一区二区三区 | 日韩一区在线播放 | 中文久久 | 欧美黄在线观看 | 成人在线视频一区 | 中文字幕亚洲欧美日韩在线不卡 | 精品综合久久 | 一区免费观看 | 欧美久久久久久久久中文字幕 | 人操人人 | 国产女人精品视频 | 国精久久 | 亚洲欧美久久 | 日韩精品成人在线 | 97色在线视频 | 女同久久另类99精品国产 | 欧美精品乱码久久久久久按摩 | 蜜桃视频在线观看免费视频网站www | 久久久久久国产精品免费免费狐狸 | 亚洲av一级毛片 | 二区三区在线观看 | 在线一区视频 | 国产96在线| 欧美日韩电影免费观看 | 亚洲va在线va天堂va狼色在线 | pacopacomama在线| 国产一区二区影院 | 欧美日韩中文字幕在线 | 米奇7777狠狠狠狠视频 |