久久久久久久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 數(shù)據(jù)庫中.

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

                但是 總是包含在我的數(shù)據(jù)庫條目中.

                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 中,' '" " 有很大的區(qū)別.注意第一個中的單引號,第二個中的雙引號.

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

                所以:' ' 將產(chǎn)生一個包含斜杠、一個 '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()函數(shù)相反.

                • 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() 函數(shù)將幫助您.如果您想在沒有格式的情況下輸出到 HTML,那么您可能不需要刪除它們,因為瀏覽器不會從 個字符呈現(xiàn)換行符.

                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.

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

                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.

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

                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模板網(wǎng)!

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

                相關文檔推薦

                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算法的實現(xiàn))
                Sending a byte array from PHP to WCF(將字節(jié)數(shù)組從 PHP 發(fā)送到 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>
                          主站蜘蛛池模板: 亚洲精品一区久久久久久 | 国产精品1区 | 天天躁日日躁狠狠很躁 | 婷婷色国产偷v国产偷v小说 | 国产伦精品一区二区三区照片91 | 中文成人在线 | 色爱综合| 婷婷综合网 | 国产成人免费视频网站高清观看视频 | 国产高清视频一区二区 | 人人擦人人 | 欧美日韩久 | 欧美在线观看一区 | 欧美成人第一页 | 久久久久www | 国产在线不卡视频 | 精品亚洲一区二区三区 | 国产精品99久久久久久宅男 | 国产成人av电影 | 日韩一区二区在线观看视频 | 成年人黄色小视频 | 亚洲精品1区 | 亚洲精品中文字幕av | 久久成人在线视频 | 成人片免费看 | 在线一级片| 中文字幕 亚洲一区 | 欧美成人激情 | 一区二区三区欧美 | 涩涩视频在线看 | 波多野结衣电影一区 | 欧美群妇大交群中文字幕 | 亚洲国产精品一区二区www | 91不卡| 亚洲福利一区二区 | 在线a视频网站 | 国产成人精品在线 | 91精品久久久久久久久久入口 | 日韩一区精品 | 欧美黄在线观看 | 精品伊人久久 |