Heim  >  Artikel  >  php教程  >  PHP处理control-M字符(^M)的方式

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

WBOY
WBOYOriginal
2016-06-06 20:09:12891Durchsuche

昨天晚上一个提交错误的问题折腾我到两点,可怜的。 表单输入的问题,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手册上的例子
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn