Home > php教程 > php手册 > body text

PHP处理control-M字符(^M)的方式

WBOY
Release: 2016-06-06 20:09:12
Original
889 people have browsed it

昨天晚上一个提交错误的问题折腾我到两点,可怜的。 表单输入的问题,jquery动态加入的input节点,form提交的时候没有附带上该input的项目,不知道怎么闹的,死活都不行,这个是其一。网上说的方式我也没有测试出正常的解决方式,所以作罢,没有继续用添加节

昨天晚上一个提交错误的问题折腾我到两点,可怜的。

表单输入的问题,jquery动态加入的input节点,form提交的时候没有附带上该input的项目,不知道怎么闹的,死活都不行,这个是其一。网上说的方式我也没有测试出正常的解决方式,所以作罢,没有继续用添加节点的方式。

另外一个就是字符串后面的^M字符的问题。这个可以导致nginx出现400的错误响应,没法处理该请求。

// if you are upset with windows' ^M characters at the end of the line,
// these two lines are for you:
$trans = array("\x0D" => "");
$text = strtr($orig_text,$trans);

// note that ctrl+M (in vim known as ^M) is hexadecimally 0x0D



这个处理方式最简洁了,可以试试,php手册上的例子
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!