2015-12-31 79 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