pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <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="mq0qq0l" 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="qnu5gma" id='IP0oz'><tfoot id='IP0oz'></tfoot><dl id='IP0oz'><fieldset id='IP0oz'></fieldset></dl></div>

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

                問題描述

                限時送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?

                推薦答案

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

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

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

                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)在將直接進(jì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)相同的目標(biāo).

                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.

                希望有所幫助.

                這篇關(guān)于用 PHP 替換 的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 異常無法連接到主機)
                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="br0oned" 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>
                          主站蜘蛛池模板: EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 电镀电源整流器_高频电解电源_单脉双脉冲电源 - 东阳市旭东电子科技 | 低气压试验箱_高低温低气压试验箱_低气压实验箱 |林频试验设备品牌 | 上海噪音治理公司-专业隔音降噪公司-中广通环保 | ZHZ8耐压测试仪-上海胜绪电气有限公司 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 药品/药物稳定性试验考察箱-埃里森仪器设备(上海)有限公司 | 阴离子聚丙烯酰胺价格_PAM_高分子聚丙烯酰胺厂家-河南泰航净水材料有限公司 | 青岛空压机,青岛空压机维修/保养,青岛空压机销售/出租公司,青岛空压机厂家电话 | 德州万泰装饰 - 万泰装饰装修设计软装家居馆 | 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 模具钢_高速钢_不锈钢-万利钢金属材料 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 上海佳武自动化科技有限公司 | 废气处理设备-工业除尘器-RTO-RCO-蓄热式焚烧炉厂家-江苏天达环保设备有限公司 | 运动木地板_体育木地板_篮球馆木地板_舞台木地板-实木运动地板厂家 | 游泳池设计|设备|配件|药品|吸污机-东莞市太平洋康体设施有限公司 | 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库 | 老房子翻新装修,旧房墙面翻新,房屋防水补漏,厨房卫生间改造,室内装潢装修公司 - 一修房屋快修官网 | SRRC认证|CCC认证|CTA申请_IMEI|MAC地址注册-英利检测 | 臭氧老化试验箱,高低温试验箱,恒温恒湿试验箱,防水试验设备-苏州亚诺天下仪器有限公司 | 汽车水泵_汽车水泵厂家-瑞安市骏迪汽车配件有限公司 | 美名宝起名网-在线宝宝、公司、起名平台 | 宁夏档案密集柜,智能密集柜,电动手摇密集柜-盛隆柜业宁夏档案密集柜厂家 | 精雕机-火花机-精雕机 cnc-高速精雕机-电火花机-广东鼎拓机械科技有限公司 | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 淘趣英语网 - 在线英语学习,零基础英语学习网站 | 半容积式换热器_北京浮动盘管换热器厂家|北京亿丰上达 | 外贮压-柜式-悬挂式-七氟丙烷-灭火器-灭火系统-药剂-价格-厂家-IG541-混合气体-贮压-非贮压-超细干粉-自动-灭火装置-气体灭火设备-探火管灭火厂家-东莞汇建消防科技有限公司 | 甲级防雷检测仪-乙级防雷检测仪厂家-上海胜绪电气有限公司 | 耐力板-PC阳光板-PC板-PC耐力板 - 嘉兴赢创实业有限公司 | 罐体电伴热工程-消防管道电伴热带厂家-山东沃安电气 | 禹城彩钢厂_钢结构板房_彩钢复合板-禹城泰瑞彩钢复合板加工厂 | 手术示教系统-数字化手术室系统-林之硕医疗云智能视频平台 | 环保袋,无纺布袋,无纺布打孔袋,保温袋,环保袋定制,环保袋厂家,环雅包装-十七年环保袋定制厂家 | 齿轮减速电机一体机_蜗轮蜗杆减速马达-德国BOSERL齿轮减速机带电机生产厂家 | 肉嫩度仪-凝胶测试仪-国产质构仪-气味分析仪-上海保圣实业发展有限公司|总部 | 南京技嘉环保科技有限公司-杀菌除臭剂|污水|垃圾|厕所|橡胶厂|化工厂|铸造厂除臭剂 | NMRV减速机|铝合金减速机|蜗轮蜗杆减速机|NMRV减速机厂家-东莞市台机减速机有限公司 | Safety light curtain|Belt Sway Switches|Pull Rope Switch|ultrasonic flaw detector-Shandong Zhuoxin Machinery Co., Ltd | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 |