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

    <bdo id='5lHOs'></bdo><ul id='5lHOs'></ul>
  1. <small id='5lHOs'></small><noframes id='5lHOs'>

    <tfoot id='5lHOs'></tfoot>
  2. <legend id='5lHOs'><style id='5lHOs'><dir id='5lHOs'><q id='5lHOs'></q></dir></style></legend>

      <i id='5lHOs'><tr id='5lHOs'><dt id='5lHOs'><q id='5lHOs'><span id='5lHOs'><b id='5lHOs'><form id='5lHOs'><ins id='5lHOs'></ins><ul id='5lHOs'></ul><sub id='5lHOs'></sub></form><legend id='5lHOs'></legend><bdo id='5lHOs'><pre id='5lHOs'><center id='5lHOs'></center></pre></bdo></b><th id='5lHOs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5lHOs'><tfoot id='5lHOs'></tfoot><dl id='5lHOs'><fieldset id='5lHOs'></fieldset></dl></div>
    1. 用 PHP 替換

      Replacing with PHP(用 PHP 替換 )

              <tbody id='IP0oz'></tbody>
          • <legend id='IP0oz'><style id='IP0oz'><dir id='IP0oz'><q id='IP0oz'></q></dir></style></legend>

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

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

                本文介紹了用 PHP 替換 的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個帖子表單,它可以將我的文本插入到 MySQL 數據庫中.

                I have a post form, which inserts my text in a MySQL database.

                我用

                $post_text = mysql_real_escape_string(htmlspecialchars($_POST['text']));
                

                并且想要替換自動添加的 .

                and want to replace the which was automatically added.

                我試過了

                $text = str_replace('\r\n','', $text);
                $text = str_replace('
                ','', $text);
                $text = str_replace('\R\N','', $text);
                $text = str_replace('RN','', $text);
                $text = str_replace('/
                \n','', $text);
                $text = str_replace('/r/n','', $text);
                $text = str_replace('/R\N','', $text);
                $text = str_replace('/R/N','', $text);
                

                但是 總是包含在我的數據庫條目中.

                but is always included in my database entries.

                我該如何解決這個問題?

                How can I fix this?

                推薦答案

                您嘗試過的所有變體的主要問題是 是轉義字符,只有在雙引號字符串中使用時才會轉義.

                The main problem you have with all the variations you've tried is that both and are escape characters that are only escaped when you use them in a double-quoted string.

                在 PHP 中,' '" " 有很大的區別.注意第一個中的單引號,第二個中的雙引號.

                In PHP, there is a big difference between ' ' and " ". Note the single-quotes in the first, and double-quotes in the second.

                所以:' ' 將產生一個包含斜杠、一個 'r'、另一個斜杠和一個 'n' 的四字符字符串,而 " " 將包含兩個字符,即換行符和回車符.

                So: ' ' will result in a four character string containing a slash, an 'r', another slash and an 'n', whereas " " will contain two characters, those being the new line and carriage return characters.

                所以直接回答你的問題是你需要使用你在問題中給出的第二個例子,但是用雙引號而不是單引號:

                So the direct answer to your question is that you need to use the second of the examples you gave in the question, but with double quotes instead of single quotes:

                $text = str_replace("
                ",'', $text);
                

                值得指出的是,這將從輸入中刪除所有新行,并將它們替換為空.如果輸入中有多個新行,它們將全部被刪除.在不了解有關您的應用程序的更多信息的情況下,我不知道這是否是您想要的,但這里有一些想法:

                It's worth pointing out that this will remove all new lines from the input, and replace them with nothing. If there is more than one new line in the input, they will all be removed. Without knowing more about your application, I don't know if this is what you want, but here are some thoughts:

                • 如果你只想從輸入字符串的end中刪除空行(和其他空格),你可以使用trim()函數相反.

                • If you only want to remove blank lines (and other white space) from the end of the input string, you can use the trim() function instead.

                如果您想保留輸出到 HTML 的格式,那么 nl2br() 函數將幫助您.如果您想在沒有格式的情況下輸出到 HTML,那么您可能不需要刪除它們,因為瀏覽器不會從 個字符呈現換行符.

                If you want to retain the formatting for output to HTML, then the nl2br() function will help you. If you want to output to HTML without the formatting, then you may not need to remove them, as the browser will not render line breaks from characters.

                如果你什么都不替換新行,根據你的例子,第一行的最后一個詞現在將直接進入第二行的第一個詞,依此類推.您可能更喜歡用空格字符替換它們,而不是什么都不替換.

                If you replace new lines with nothing, as per your example, the last word of the first line will now run directly into the first word of the second line, and so on. You may prefer to replace them with a space character rather than nothing.

                用戶可能提交只有 而沒有匹配 的輸入,反之亦然(這可能是由于他們的操作系統或瀏覽器,或故意黑客攻擊,或許多其他原因).如果您想替換這兩個字符的所有 實例,一種更可靠的方法是單獨替換它們,而不是依賴它們彼此相鄰.str_replace() 允許您通過在數組中指定它們來執行此操作.您還可以使用 strtr()preg_replace() 來實現相同的目標.

                It is possible that users may submit the input with only without the matching , or vice-versa (this may be due to their OS or browser, or a deliberate hack, or a number of other reasons). If you want to replace all instances of both these characters, a more reliable way to do it would be to replace them individually, rather than relying on them being next to one-another. str_replace() allows you to do this by specifying them in an array. You can also use strtr() or preg_replace() to achieve the same goal.

                希望有所幫助.

                這篇關于用 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)
                <legend id='qKZit'><style id='qKZit'><dir id='qKZit'><q id='qKZit'></q></dir></style></legend>

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

                    • <tfoot id='qKZit'></tfoot>

                          <tbody id='qKZit'></tbody>
                          <bdo id='qKZit'></bdo><ul id='qKZit'></ul>
                          主站蜘蛛池模板: 国产一区二区三区在线 | 亚洲欧美成人在线 | 久久免费看 | 天天精品在线 | 国产精品久久久久久久久久久久 | 欧美精品在线一区 | 一区二区三区四区不卡 | 日韩综合在线 | 成人在线免费观看视频 | 亚洲a一区| 久久一及片 | 久久久激情 | 久久久久亚洲av毛片大全 | 久久久精品一区二区三区四季av | 日本特黄特色aaa大片免费 | 在线成人免费视频 | 精品国产一区二区三区久久久蜜月 | 国产高清一区二区三区 | 国产精品日韩欧美一区二区三区 | 巨大黑人极品videos精品 | 日韩欧美三级在线 | 免费亚洲视频 | 亚洲一区视频在线 | 亚洲一区二区久久 | 欧美激情国产日韩精品一区18 | 日本精品一区二区三区在线观看视频 | 久久亚洲综合 | 你懂的av| 亚洲网站在线观看 | 狠狠色综合久久婷婷 | 欧美福利在线 | jlzzjlzz欧美大全 | 国产精品一区久久久 | 日本亚洲一区 | www四虎影视 | 国产精品国产精品国产专区不卡 | 在线观看免费观看在线91 | 一级黄色绿像片 | 日韩成人| 日日碰碰| 亚洲国产精品第一区二区 |