-1

警告:无法修改标头信息 - 标头已由第 19 行 /sms.php 中的(输出开始于 /sms.php:9)发送

当我在下面使用此代码时发生这种情况。我想将页面重定向到我网站中的另一个页面

$username = '';
    $password = '';
    $client = new SoapClient('http://www.xxxx/xx');
    $numbers = 'xxxx ';
    $message = 
    'hi this is a test 
    !@#$%^&*
    ';
    $senderName = 'xxxxxx';
    try {
    $response = $client->sendSMS($username, $password, $numbers, $message, $senderName);
    var_dump($response);
    header('Location: http://www.yoursite.com/new_page.html');
    } catch(SoapFault $exception ) {
    echo $exception->faultcode . ' : ' .$exception->faultstring . PHP_EOL;
    }
4

1 回答 1

1

var_dump($response);在使用 header() 之前,您正在尝试使用语句打印输出。ob_start()在任何输出之前移动你的 header() 函数,或者使用和将你的代码包装在输出缓冲区中ob_end_flush()

http://php.net/manual/it/function.ob-start.php

http://www.php.net/manual/it/function.ob-end-flush.php

于 2013-09-07T00:08:48.897 回答