收到警告“标头不得包含单个标头,已检测到新行". [英] getting warning "Header may not contain more than a single header, new line detected"

查看:332
本文介绍了收到警告“标头不得包含单个标头,已检测到新行".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做代码编码,以便在PHP中上传图片.但是提交图片后,它会发出警告

I am doing coding in oops for uploading image in PHP. But After submit image, it's giving warning

标头不能包含多个标头,已检测到新行"

"Header may not contain more than a single header, new line detected"

下面是我的函数,在该函数上给出错误

Below is my function, on which its giving error

public function ft_redirect($query = '') {

    if (REQUEST_URI) {

        $_SERVER['REQUEST_URI'] = REQUEST_URI;

    }

    $protocol = 'http://';

    if (HTTPS) {

        $protocol = 'https://';
    }

    if (isset($_SERVER['REQUEST_URI'])) {

        if (stristr($_SERVER["REQUEST_URI"], "?")) {

            $requesturi = substr($_SERVER["REQUEST_URI"], 0, strpos($_SERVER["REQUEST_URI"], "?"));

            $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$requesturi}";
        } else {


            $requesturi = $_SERVER["REQUEST_URI"];

            $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$requesturi}";

        }

    } else {

        $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$_SERVER['PHP_SELF']}";

    }

    if (!empty($query)) {

        $location .= "?{$query}";

    }

    header($location);

    exit;

}

推荐答案

URL地址中的行不应超过两行.检查您的网址.

You shouldn't put more than two lines in URL address. Check you URL.

Good URL - "http://mail.google.com"  - 1 line

Bad URL - "http://mail.              - 2 lines
            google.com/"

这篇关于收到警告“标头不得包含单个标头,已检测到新行".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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