Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:无法修改标题信息-标题已由发送_Php_Header - Fatal编程技术网

Php 警告:无法修改标题信息-标题已由发送

Php 警告:无法修改标题信息-标题已由发送,php,header,Php,Header,每当我试图改变某些东西时,我都会遇到标题中提到的错误。我试着查了一下,但我不太明白我找到的答案。导致此错误的原因以及如何修复它。例如,我尝试更改a href链接,但不知道是什么原因导致了此错误。在我认为它与php代码头的顺序有关之前,它应该始终位于主体之前,之后就不能再更改头了。但是如果像a href链接这样的小事情可以导致它,那么还有其他事情在发生 警告:无法修改标题信息-标题已由发送 (输出开始于 /home/nieuwsman/domains/cdwp.publiceer.net/publ

每当我试图改变某些东西时,我都会遇到标题中提到的错误。我试着查了一下,但我不太明白我找到的答案。导致此错误的原因以及如何修复它。例如,我尝试更改a href链接,但不知道是什么原因导致了此错误。在我认为它与php代码头的顺序有关之前,它应该始终位于主体之前,之后就不能再更改头了。但是如果像a href链接这样的小事情可以导致它,那么还有其他事情在发生

警告:无法修改标题信息-标题已由发送 (输出开始于 /home/nieuwsman/domains/cdwp.publiceer.net/public_html/wp content/themes/wpoupon_mollie/ideal.class.php:1) 在里面 /home/nieuwsman/domains/cdwp.publiceer.net/public_html/wp-content/themes/wpoupon_mollie/functions.php 第28行


}

当您已经打印了内容,并且稍后调用
header()
函数时,会发生此错误

在这里:

echo $iDEAL->getBankURL();
您正在显示一些文本。开始显示某些内容后,不能使用
标题(“位置”)
。 如果要使用
标题(“位置”)
执行重定向,请删除此
echo

if ($iDEAL->createPayment($_POST['bank_id'], $amount, $description, $return_url, $report_url)) 
{           
    // Removed line : this content should never been displayed since you're redirecting just after.
    header("Location: " . $iDEAL->getBankURL());
    exit;   
} else {
    echo $iDEAL->getErrorMessage();
}
写入
ob_start()在php页面的顶部。

希望这对您有用。

您好,请出示您的代码?我们在这里看不懂你的心思。请在问题中填写错误和代码。的副本。如果你使用页面顶部的搜索引擎,很容易找到。在这里。我在调用
header
之前删除了该行,这应该可以工作。如果我删除回音,我仍然会收到错误消息,只是URL消失了。我只希望代码转到此处提供的链接。请用您的更改更新原始邮件中的代码。我刚刚用当前使用的代码更新了主要帖子。好的。如果仍然存在错误,则意味着某些内容显示在
标题
调用之前,可能在其他地方。检查要导入的文件
ideal.class.php
protected function _sendRequest ($host, $port, $path, $data)
{
    if (function_exists('curl_init')) {
        return $this->_sendRequestCurl($host, $port, $path, $data);
    }
    else {
        return $this->_sendRequestFsock($host, $port, $path, $data);
    }
}

protected function _sendRequestFsock ($host, $port, $path, $data)
{
    $hostname = str_replace('ssl://', '', $host);
    $fp = @fsockopen($host, $port, $errno, $errstr);
    $buf = '';

    if (!$fp)
    {
        $this->error_message = 'Kon geen verbinding maken met server: ' . $errstr;
        $this->error_code       = 0;

        return false;
    }

    @fputs($fp, "POST $path HTTP/1.0\n");
    @fputs($fp, "Host: $hostname\n");
    @fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
    @fputs($fp, "Content-length: " . strlen($data) . "\n");
    @fputs($fp, "Connection: close\n\n");
    @fputs($fp, $data);

    while (!feof($fp)) {
        $buf .= fgets($fp, 128);
    }

    fclose($fp);

    if (empty($buf))
    {
        $this->error_message = 'Zero-sized reply';
        return false;
    }
    else {
        list($headers, $body) = preg_split("/(\r?\n){2}/", $buf, 2);
    }

    return $body;
}

protected function _sendRequestCurl ($host, $port, $path, $data)
{
    $host = str_replace('ssl://', 'https://', $host);

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $host . $path);
    curl_setopt($ch, CURLOPT_PORT, $port);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);        

    $body = curl_exec($ch);

    curl_close($ch);

    return $body;   
}

protected function _XMLtoObject ($xml)
{
    try
    {
        $xml_object = new SimpleXMLElement($xml);
        if ($xml_object == false)
        {
            $this->error_message = "Kon XML resultaat niet verwerken";
            return false;
        }
    }
    catch (Exception $e) {
        return false;
    }

    return $xml_object;
}

protected function _XMLisError($xml)
{
    if (isset($xml->item))
    {
        $attributes = $xml->item->attributes();
        if ($attributes['type'] == 'error')
        {
            $this->error_message = (string) $xml->item->message;
            $this->error_code    = (string) $xml->item->errorcode;

            return true;
        }
    }

    return false;
}


/* Getters en setters */
public function setProfileKey($profile_key)
{       
    if (is_null($profile_key))
        return false;

    return ($this->profile_key = $profile_key);
}

public function getProfileKey()
{
    return $this->profile_key;
}

public function setPartnerId ($partner_id)
{
    if (!is_numeric($partner_id)) {
        return false;
    }

    return ($this->partner_id = $partner_id);
}

public function getPartnerId ()
{
    return $this->partner_id;
}

public function setTestmode ($enable = true)
{
    return ($this->testmode = $enable);
}

public function setBankId ($bank_id)
{
    if (!is_numeric($bank_id))
        return false;

    return ($this->bank_id = $bank_id);
}

public function getBankId ()
{
    return $this->bank_id;
}

public function setAmount ($amount)
{
    if (!preg_match('~^[0-9]+$~', $amount)) {
        return false;
    }

    if (self::MIN_TRANS_AMOUNT > $amount) {
        return false;
    }

    return ($this->amount = $amount);
}

public function getAmount ()
{
    return $this->amount;
}

public function setDescription ($description)
{
    $description = substr($description, 0, 29);

    return ($this->description = $description);
}

public function getDescription ()
{
    return $this->description;
}

public function setReturnURL ($return_url)
{
    if (!preg_match('|(\w+)://([^/:]+)(:\d+)?(.*)|', $return_url))
        return false;

    return ($this->return_url = $return_url);
}

public function getReturnURL ()
{
    return $this->return_url;
}

public function setReportURL ($report_url)
{
    if (!preg_match('|(\w+)://([^/:]+)(:\d+)?(.*)|', $report_url)) {
        return false;
    }

    return ($this->report_url = $report_url);
}

public function getReportURL ()
{
    return $this->report_url;
}

public function setTransactionId ($transaction_id)
{
    if (empty($transaction_id))
        return false;

    return ($this->transaction_id = $transaction_id);
}

public function getTransactionId ()
{
    return $this->transaction_id;
}

public function getBankURL ()
{
    return $this->bank_url;
}

public function getPaymentURL ()
{
    return (string) $this->payment_url;
}

public function getPaidStatus ()
{
    return $this->paid_status;
}

public function getBankStatus()
{
    return $this->status;
}

public function getConsumerInfo ()
{
    return $this->consumer_info;
}

public function getErrorMessage ()
{
    return $this->error_message;
}

public function getErrorCode ()
{
    return $this->error_code;
}
echo $iDEAL->getBankURL();
if ($iDEAL->createPayment($_POST['bank_id'], $amount, $description, $return_url, $report_url)) 
{           
    // Removed line : this content should never been displayed since you're redirecting just after.
    header("Location: " . $iDEAL->getBankURL());
    exit;   
} else {
    echo $iDEAL->getErrorMessage();
}