标题在我的服务器上不起作用 [英] Header does not work on my server

查看:105
本文介绍了标题在我的服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在我的服务器上有一个小问题:

当我使用php标题功能时,它不起作用:

  header('location:/index.html'); 

我在另一台具有相同php版本的服务器上尝试了这一行,它工作的很好!



PHP版本:5.1.65



请有任何建议?

解决方案

正如Dylan Cross提到的,你不能在标题前输出HTML。



如果你在调用头部,它可能包含html,而没有引起足够的重视 - 以下面的方式:

 <?php 

//这里的代码

?> {如果在这个关闭标签之后有一个空格,它被认为是HTML输出}

在这种情况下,您需要检查所有库...


Please I have a small problem on my server :

When I use the php "header" function, it doesn't work :

header('location: /index.html');

I tried this line on another server with the same php version and it works finely !

PHP version : 5.1.65

Please any advice ?

解决方案

As Dylan Cross mentioned you mustn't have HTML output before the header.

If you have required a library before calling "header", it might contain the html -without paying attention- in the fallowing way :

<?php 

   // Code here

?>{If there is a space after this close tag, it's considered as an HTML output}

In this case you need to check all your libraries...

这篇关于标题在我的服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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