PHP的header()函数中的CRLF(\\\ n) [英] CRLF (\r\n) in PHP's header() function

查看:458
本文介绍了PHP的header()函数中的CRLF(\\\ n)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么/何时必须在PHP的标题末尾使用CRLF?
这是一个例子(它不一定正确):

Why/when does one has to use CRLF's at the end of header in PHP? Here is one example (it's not necessarily correct):

header("method: POST\r\n");
header('Host: '.get_option('transact_url')."\r\n");
header('Content-type: application/x-www-form-urlencoded');
header('Content-length: '.strlen($transaction)."\r\n");
header($transaction."\r\n\r\n");
header("Connection: close\r\n\r\n");
header("Location: ".$key_client_url."\r\n");


推荐答案

你绝不应该在内部进行手动换行a href =http://de2.php.net/manual/en/function.header.php =nofollow>标题()。当前的实现删除了换行符,因此您可以安全,但这可能会在将来发生变化(尽管没有理由将其更改)。

You should never do manual line-breaks inside of header(). The current implementation removes line-breaks so you're safe, but this could change in future (although there's no reason why it should be changed).

这篇关于PHP的header()函数中的CRLF(\\\ n)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆