**警告**:在PHP中使用未定义的常量HTTP_HOST]

**警告**:在PHP中使用未定义的常量HTTP_HOST],php,Php,我在下面的代码中遇到了一个bug(这是Gmod加载屏幕的基本文件) 我目前正在将PHP站点从一个Web服务器移动到一个自托管的Web服务器。它运行的Nginx指向PHP。关于这个问题: 如果我只是将其加载到新网站上,则会出现以下错误: 警告:在C:\Websites\Readling\index.PHP的第13行使用未定义的常量HTTP\u HOST-假定为“HTTP\u HOST”(这将在未来版本的PHP中引发错误) 警告:在C:\Websites\Readling\index.PHP的第13

我在下面的代码中遇到了一个bug(这是Gmod加载屏幕的基本文件)

我目前正在将PHP站点从一个Web服务器移动到一个自托管的Web服务器。它运行的Nginx指向PHP。关于这个问题: 如果我只是将其加载到新网站上,则会出现以下错误:

警告:在C:\Websites\Readling\index.PHP的第13行使用未定义的常量HTTP\u HOST-假定为“HTTP\u HOST”(这将在未来版本的PHP中引发错误)
警告:在C:\Websites\Readling\index.PHP的第13行使用未定义的常量REQUEST\u URI-假定为“REQUEST\u URI”(这将在未来版本的PHP中引发错误)

在做了想要的消息后,认为网站没有加载。停用错误报告也是如此。我不知道怎么了,我对PHP也不太了解。我已经尝试了多个PHP版本,但没有任何帮助。我只是想让它像在其他Web服务器上一样工作

如果您对调试信息等有任何疑问,请解释我在哪里可以找到它。我在这方面没有那么多线索(这可能是我的老问题被关闭的原因)谢谢你的时间,祝你度过愉快的一天:)


您发布的代码不会触发警告。搜索按原样使用
HTTP\u HOST
的代码,您将找到原因。中解释了此警告的原因和解决方案。index.php中的第13行是什么样子的?错误与您在index.php的第13行发布的代码不匹配请确保它们是
$\u SERVER['HTTP\u HOST']
而不是
$\u SERVER[HTTP\u HOST]
,可能缺少引号?@Bosman如果我这样做,页面将不会加载任何css
    <?php
ini_set( "display_errors", 1);
// A Steam API Key is required so as to be able to contact steam and get a users profile image and name
// You can get a Steam API Key by visiting http://steamcommunity.com/dev/apikey
// Don't worry about the web address, it won't have any effect so just type in any web site
// Once you have your steam API Key simply paste the key below. (Make sure the quotation marks are still there or else it won't work)
$SteamAPIKey = "XXXXXXXXXXXXXXXXXXXX";
    
$error_url = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$error_url_test = $error_url . '?steamid=76561198000430367';
$error_url_server = $error_url . '?steamid=%s';

if (!isset($_GET["steamid"])) {
    die("Woops, you don't seem to be using the correct extension in the address bar to get the loading screen to work.<br />
    Please make sure it has the correct extension it should have ?steamid= at the end of it and look something like this: www.yourdomain.com/loading/index.php?steamid=%s<br /><br />

    You can use the link below which will automatically add a test steam id to see if your loading screen is configured properly<br />
    <a href='$error_url_test'>$error_url_test</a><br /><br />
    
    When setting your loading url please make sure you set the steam id to %s as shown in the link below<br />
    <a href='$error_url_server'>$error_url_server</a>
    
    ");
}

$steamid64 = $_GET["steamid"];

$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . $SteamAPIKey . "&steamids=" . $steamid64;
$json = file_get_contents($url);
$table2 = json_decode($json, true);
$table = $table2["response"]["players"][0];

?>

<!DOCTYPE HTML>
<html>
    <head>
    <!-- Hello, your reading the source code for the server load page -->
    <!-- Created by CaptainMcMarcus for CoderHire -->
    <!-- This is the HTML code below and is safe to edit to your needs -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <meta name="description" content="Wilkommen - Loading..." /> <!-- Webpage Description --> 
    <title>Hofload</title> <!-- Webpage Title -->
    <link href="style.css" rel="stylesheet" type="text/css" /> <!-- Links to the Stylesheet -->
    <link href="./colour.css" rel="stylesheet" type="text/css" /> <!-- Links to the Stylesheet for main colours -->
    
    <script type="text/javascript" src="scripts/jquery.js"></script><!-- Link to jquery so we can do cool stuff -->
    <script type="text/javascript" src="scripts/cycle.js"></script><!-- For Rotating Backgrounds -->
    
    <script type="text/javascript"><!-- Script to center content -->
    $(document).ready(function() {
        //Changes volume of song. 0.5=50% volume
        $('.audio').prop("volume", 0.9);
            
        //Perfectly centers content to the middle of the screen both vertically and horizontally
        $(window).resize(function(){
              $('.core-wrapper').css({
               position:'absolute',
               left: ($(window).width() 
                 - $('.core-wrapper').outerWidth())/2,
               top: ($(window).height() 
                 - $('.core-wrapper').outerHeight())/2
              });   
        });
        
        
        //Lets get those backgrounds moving
        $('#background-scroll').cycle({ 
            fx: 'fade',
            pause: 0, 
            speed: 4500, //Time to fade into the next image [in milliseconds]
            timeout: 3500  //Time spent on image [in milliseconds]
        });     
        //Lets get those pictures moving
        $('#img-scroll').cycle({ 
            fx: 'fade',
            pause: 0, 
            speed: 4500, //Time to fade into the next image [in milliseconds]
            timeout: 2500  //Time spent on image [in milliseconds]
        });
        // Initiate center function
        $(window).resize();
    });
    </script>
    

    </head>
    
    <body>
    
    <div id="background-scroll"><!-- Add Backgrounds so we can have multiple ones -->
        <!-- IF YOU NEED LESS BACKGROUNDS JUST REMOVE THEM OUT OF THE LIST -->
        <!-- TO ADD EXTRA BACKGROUNDS YOU NEED TO MODIFY THE STYLESHEET [ADVANCED USERS ONLY] -->
        <div id="bg1"></div><!-- BG 1 -->
        <div id="bg2"></div><!-- BG 2 -->
        <div id="bg3"></div><!-- BG 3 -->
        <div id="bg4"></div><!-- BG 4 -->
        <div id="bg5"></div><!-- BG 5 -->
        <div id="bg6"></div><!-- BG 6 -->
        <div id="bg7"></div><!-- BG 7 -->   
        <div id="bg8"></div>
        <div id="bg9"></div>
    </div>
    
    <div class="core-wrapper"><!-- Opens the wrapper so we can contain and center everything -->
        
        <img src="images/logo.png" width="960" height="120" alt="Your Logo" /><!-- This adds in the logo, simply change logo.png to make this look different -->
    
        <div id="left-items"><!-- Opens the wrapper for the left content, there isn't really much to change on the left side as it's dynamic -->
    
            <?php
                //PHP Code for the avatar display, it's probably best to leave this section alone
                echo "<div id=\"profile-wrap\">";
                    
                    //Add in the players avatar
                    echo "<div id=\"profile-top\">";
                        echo "<div id=\"avatarimg\">";
                            echo "<img src=\"" . $table["avatarfull"] . "\" />";
                        echo "</div>";
                    echo "</div>";
                    
                    //Adds in the players name
                    echo "<div id=\"profile-bottom\">";
                        echo "<p>" . $table["personaname"] . "</p>";
                    echo "</div>";
                    
                echo "</div>";
            ?>
            <div class="clear"></div>
            
            <!--<li><img src="images/asuna.png" alt="Asuna SAO" name="asuna" style="position:absolute;top:50px;left:180px;z-index:-1;width:350px;height:350px;"/></li>-->
            <div class="title server">
                <h2>Hof Lan</h2><!-- Adds in the server title, you can change the text to be whatever you would like -->
            </div>
            
            <!-- Lets get the server Details in here -->
            <ul id="server-list">
                
                <li><img src="images/server-name.png" alt="Server Name" /> <span id="s-name">Server Name</span></li><!-- Dynamically adds the server name -->
                <li><img src="images/server-mode.png" alt="Game Mode" /> <span id="s-mode">Server Game Mode</span></li><!-- Dynamically adds game mode name -->
                <li><img src="images/server-map.png" alt="Map Name" /> <span id="s-map">Server Map Name</span></li><!-- Dynamically adds map name -->
            <div id="img-scroll"><!-- Add Backgrounds so we can have multiple ones -->
                <!-- IF YOU NEED LESS BACKGROUNDS JUST REMOVE THEM OUT OF THE LIST -->
                <!-- TO ADD EXTRA BACKGROUNDS YOU NEED TO MODIFY THE STYLESHEET [ADVANCED USERS ONLY] -->   

            </div>
            
            </ul>
            
        </div><!-- Close The Wrapper for the Left Items -->
        
        <div id="right-items"><!-- Open wrapper for the items on the right -->
            
            <div class="title">
                <h2>Regeln</h2><!-- Adds in the rules title, you can change the text to be whatever you would like -->
            </div>
            
            <!-- Let's add in all the rules, the number inside the <span></span> tags will appear in a brighter colored box  -->
            <ul id="rules">
                <li><span>1</span> Kein RDMen</li>
                <li><span>2</span> Fair Play bitte</li>
                <li><span>3</span> New Live regel bezogen auf Maps.</li>
                <li><span>4</span> Nicht Beleidigen</li>
                <li><span>5</span> Propkillen erlaubt.</li>
                <li><span>6</span> Nicht  DDossen.</li>
                <li><span>7</span> Kein Spamen</li>
                <li><span>8</span> Kein Bug Ambusing</li>
                <li><span>9</span> Nicht unnötig Trollen </li>

            </ul>
            <!--<li><img src="images/mirai.png" alt="Mirai Kyoukai no Kanata" name="mirai" style="position:absolute;top:0px;right:0px;z-index:-1;width:350px;height:350px;"/></li>-->
        </div><!-- This close the right content wrapper -->
        
        <div class="clear"></div><!-- This clears things up so that we can vertically align things correctly -->
 <?php
    
    $musiclist = [
    1 => "music/1.ogg",
    2 => "music/2.ogg",
    3 => "music/3.ogg",
    4 => "music/4.ogg",
    5 => "music/5.ogg",
    6 => "music/6.ogg",
    7 => "music/7.ogg",
    8 => "music/8.ogg",
    9 => "music/9.ogg",
    10 => "music/10.ogg",
    11 => "music/11.ogg",
    12 => "music/12.ogg",
    13 => "music/13.ogg",
    14 => "music/14.ogg",
    15 => "music/15.ogg",
    16 => "music/16.ogg",
    17 => "music/17.ogg",
    18 => "music/18.ogg",
    19 => "music/19.ogg",
    20 => "music/20.ogg",
    21 => "music/21.ogg",
    22 => "music/22.ogg",
    23 => "music/23.ogg",
    24 => "music/24.ogg",
    25 => "music/25.ogg",
    26 => "music/26.ogg",
    


    ];
    $musicname = [
    1 => "Kerstin Ott & Helene Fischer - Regenbogenfarben",
    2 => "Barack Obama - 1999",
    3 => "My Little Pony - Theme Song",
    4 => "Puhdys - Dezembertage",
    5 => "SAINt JHN - Roses",
    6 => "Thomas the Tank engine - Theme song",
    7 => "The White Stripes & Gabe Prusa - Seven Nation Army (Glitch Mob Remix)",
    8 => "The 4Head - Ocean Man Voice Crack",
    9 => "Pink Fonk - Baby Shark EARRAPE",
    10 => "Mr. Rucki Peng - Weinachten am Altschauerberg (feat. Rainer)",
    11 => "Nintendo - Wii Sports Theme",
    12 => "Tim Tupet - Tote Enten",
    13 => "Hype Awards - BERLIN WAS GEHT AB",
    14 => "Nickelodeon - Krusty Krab Trap Mix",
    15 => "Erik Follestad og Linni Meister - Juletragedien",
    16 => "Bibi und Tina Theme - Remix",
    17 => "Möhre - 20 Zentimeter",
    18 => "Dschingis Kahn - Moskau (Remix)",
    19 => "Goodybe Moonman - Rick and Morty",
    20 => "Fortnite Anthem (Danke Felix <3)",
    21 => "Ikke Hüftgold - Salz auf die Eier",
    22 => "Snob Livees Matter - Peter Smits",
    23 => "Helikopter 117 - Tobee/ Extreme Sound",
    24 => "Da Coconut Nut (Coconut Song) - Jeff Lau",
    25 => "Irgendwelche Chinesen - Chinese Song",
    26 => "Woods Tune - Santa Woodie"
    ];
    $rand = rand(1,sizeof($musiclist));
    
    echo '<audio id="bgmusic" class="audio" autoplay autobuffer="autobuffer" volume="0.9">';
        echo '<source src='.$musiclist[$rand].' type="audio/ogg">';
    echo '</audio>' ;
    echo '<div id="songbg"><h3 id="mc"> Music: </h3><h4 id="song">'.$musicname[$rand].'</div>';

 ?>       
        <!-- This adds in the progress bar -->
        <div id="bar">
            <div id="bar-width" style="width: 0%;"></div>
        </div>
        
        <!-- This adds in the progress percentage bar -->
        <div id="percentage">
            <p></p>
        </div>
        
        <!-- This adds the current item being downloaded, we use the word connecting by default because if we don't download anything then it won't change -->
        <div id="download-item">
            <p>Connecting...</p>
        </div>
    
    
    
    <!-- MUSIC SCRIPT -->
    <!-- To activate simply delete the comment tags and replace music.mp3 with the path to your sound file. -->
    <!-- Adding copyrighted music is illegal as you will be redistributing from the server this is hosted from, this means that you will be held liable -->
    
    <!--
    <audio class="audio" autoplay autobuffer="autobuffer">
        <source src="music.ogg" type="audio/ogg">
    </audio>
 -->
 
    </div><!-- now we close the core wrapper to keep everything nicely contained and in the middle -->
    <script type="text/javascript" src="scripts/main.js"></script><!-- Script to get downloads, map, players, game mode and sort out the loading bar -->

    </body><!-- Closes off the HTML Document -->
</html>