解析错误:语法错误,文件意外结束

时间:2015-12-31 11:47:08

标签: php

我收到" 解析错误:语法错误,第123行的C:\ xampp \ htdocs \ football \ index.php中意外的文件结尾 "我的网络服务器上的错误(使用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>

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

alternative PHP syntax。您不能像<?php foreach ($fixtures as $fixture) { ?> <?php } ?>而是<?php foreach ($fixtures as $fixture): ?> <?php endforeach; ?>

那样使用它

答案 1 :(得分:0)

您应该避免使用此gmail.users.labels.list()及其:{?>

你不应该将括号直接放在开/关php标签附近,但是它用空格分开:<?php}也避免使用{ ?> <?php {并使用<?

相关问题