2015-12-31 112 views
-1

意外的文件結尾我得到了「解析錯誤:語法錯誤的C文件的,意想不到的結尾:\ XAMPP \ htdocs中\在線足球\的index.php 123」我的網絡服務器出錯(使用XAMPP)。我的代碼如下:解析錯誤:語法錯誤,在

<?php 
include 'FootballData.php'; 
?> 

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   
    <title>phplib football-data.org</title> 
    <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet" />  
</head> 
<body> 
    <div class="container">   
      <div class="page-header"> 
       <h1>Showcasing some library functions...</h1> 
      </div> 
      <?php 
      // Create instance of API class 
      $api = new FootballData();    
      // fetch and dump summary data for premier league' season 2015/16 
      $soccerseason = $api->getSoccerseasonById(398);       
      echo "<p><hr><p>"; ?>    
      <h3>Fixtures for the 1st matchday of <? echo $soccerseason->payload->caption; ?></h3> 
      <table class="table table-striped">      
       <tr> 
       <th>HomeTeam</th> 
       <th></th> 
       <th>AwayTeam</th> 
       <th colspan="3">Result</th> 
       </tr> 
       <?php foreach ($soccerseason->getFixturesByMatchday(1) as $fixture) { ?>    
       <tr> 
        <td><? echo $fixture->homeTeamName; ?></td> 
        <td>-</td> 
        <td><? echo $fixture->awayTeamName; ?></td> 
        <td><? echo $fixture->result->goalsHomeTeam; ?></td> 
        <td>:</td> 
        <td><? echo $fixture->result->goalsAwayTeam; ?></td> 
       </tr> 
       <? } ?> 
      </table>    
     <?  
      echo "<p><hr><p>";    
      // fetch all available upcoming fixtures for the next week and display 
      $now = new DateTime();    
      $end = new DateTime(); $end->add(new DateInterval('P7D'));       
      $response = $api->getFixturesForDateRange($now->format('Y-m-d'), $end->format('Y-m-d')); 
     ?> 
     <h3>Upcoming fixtures next 7 days</h3> 
      <table class="table table-striped">     
       <tr> 
        <th>HomeTeam</th> 
        <th></th> 
        <th>AwayTeam</th> 
        <th colspan="3">Result</th> 
       </tr> 
       <?php foreach ($response->fixtures as $fixture) { ?>    
       <tr> 
        <td><? echo $fixture->homeTeamName; ?></td> 
        <td>-</td> 
        <td><? echo $fixture->awayTeamName; ?></td> 
        <td><? echo $fixture->result->goalsHomeTeam; ?></td> 
        <td>:</td> 
        <td><? echo $fixture->result->goalsAwayTeam; ?></td> 
       </tr> 
       <? } ?> 
      </table> 

     <?  
      echo "<p><hr><p>";    
      // search for desired team 
      $searchQuery = $api->searchTeam(urlencode("Real Madrid")); 
      // var_dump searchQuery and inspect for results 
      $response = $api->getTeamById($searchQuery->teams[0]->id); 
      $fixtures = $response->getFixtures('home')->fixtures; 
     ?> 
      <h3>All home matches of Real Madrid:</h3> 
      <table class="table table-striped">      
       <tr> 
        <th>HomeTeam</th> 
        <th></th> 
        <th>AwayTeam</th> 
        <th colspan="3">Result</th> 
       </tr> 
       <?php foreach ($fixtures as $fixture) { ?>    
       <tr> 
        <td><? echo $fixture->homeTeamName; ?></td> 
        <td>-</td> 
        <td><? echo $fixture->awayTeamName; ?></td> 
        <td><? echo $fixture->result->goalsHomeTeam; ?></td> 
        <td>:</td> 
        <td><? echo $fixture->result->goalsAwayTeam; ?></td> 
       </tr> 
       <? } ?> 
      </table> 



     <?  
      echo "<p><hr><p>";    
      // fetch players for a specific team    
      $team = $api->getTeamById($searchQuery->teams[0]->id); 
     ?> 
     <h3>Players of <? echo $team->_payload->name; ?></h3> 
     <table class="table table-striped">     
      <tr> 
       <th>Name</th> 
       <th>Position</th> 
       <th>Jersey Number</th> 
       <th>Date of birth</th>  
      </tr> 
      <? foreach ($team->getPlayers() as $player) { ?> 
      <tr> 
       <td><? echo $player->name; ?></td> 
       <td><? echo $player->position; ?></td> 
       <td><? echo $player->jerseyNumber; ?></td> 
       <td><? echo $player->dateOfBirth; ?></td> 
      </tr>    
      <? } ?> 
     </table> 
    </div> 
</body> 
</html> 

我該如何解決這個問題?

+0

你檢查了哪一行是你的行:123的錯誤? –

+0

第123行實際上是文件的結尾。 「」 –

+0

從php.ini啓用short_open_tag或使用完整語法<?php – devpro

回答

0

請參閱alternative PHP syntax。你不能這樣使用它<?php foreach ($fixtures as $fixture) { ?> <?php } ?><?php foreach ($fixtures as $fixture): ?> <?php endforeach; ?>

0

你應該避免這種{?>這:<?php}

你不應該把括號直接貼近打開/關閉PHP的標籤,但它用空格分隔:{ ?> <?php {也避免<?和使用<?php