后'头'功能输出 [英] Output after 'header' function

查看:183
本文介绍了后'头'功能输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code是这样的:

I have the code like this:

<?php
header('Location: http://www.example.com/');
echo 'Hello';

,我不知道会是什么code的结果。我知道 - 浏览器获得头&放大器;重定向到http://www.example.com/。
但是,关于头功能后的输出是什么?其中字符串你好将被发送?
如果broser会接受呢?

And i'm wondering what would be the result of the code. I know - the browser gets header & redirects to 'http://www.example.com/'. But what about the output after the 'header' function? Where the string 'Hello' will be sent? If the broser will receive it?

推荐答案

头() 被用来发送一个原始HTTP标头

header() is used to send a raw HTTP header

这将在其头部发送重定向(不同的HTTP code,重定向302 ),以及与内容'你好'

It will send out the redirect in its header (different HTTP code, REDIRECT 302), along with the content 'Hello'.

响应头首先由web浏览器处理移动到任何内容之前。
因此,这样的HTTP响应的内容将不会被读取或由浏览器处理。

The response headers are processed first by the web-browser before moving on to any content. Hence, the content of such an HTTP response will not be read or processed by the browser.

更多: HTTP 302

More: HTTP 302

这篇关于后'头'功能输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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