我在文件末尾出现问题,如下图所示
错误显示在页面末尾,表示</HTML>
。我试图编辑该文件没有任何成功,所以我需要有人给我这样的提示我在代码中的问题。
请帮我理解我的问题所在。
谢谢您的帮助。
<?php
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
session_start();
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiPagespeedonlineService.php';
$client = new apiClient();
$client->setApplicationName("PageSpeedOnline_Example_App");
$service = new apiPagespeedonlineService($client);
if (isset($_GET['url'])) {
$result = $service->pagespeedapi->runpagespeed($_GET['url']);
}
?>
<!doctype html>
<html>
<head><link rel='stylesheet' href='style.css' /></head>
<body>
<header><h1>Google Page Speed Sample App</h1></header>
<div class="box">
<div id="search">
<form id="url" method="GET" action="index.php">
<input name="url" class="url" type="text">
<input type="submit" value="Analyze Performance">
</form>
</div>
<?php if (isset($result)): ?>
<div class="result">
<h3>Summary</h3>
<?php print $result['title']; ?> got a PageSpeed Score of <b><?php print $result['score']; ?></b> (out of 100).
<div>Title: <?php print $result['title']; ?></div>
<div>Score: <?php print $result['score']; ?></div>
<div>Number of Resources: <?php print $result['pageStats']['numberResources']; ?></div>
<div>Number of Hosts: <?php print $result['pageStats']['numberHosts']; ?></div>
<div>Total Request Bytes: <?php print $result['pageStats']['totalRequestBytes']; ?></div>
<div>Number of Static Resources: <?php print $result['pageStats']['numberStaticResources']; ?></div>
<pre><?php var_dump($result); ?></pre>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
缺少
<?php endif; ?>
<?php if (isset($result)): ?>
它应该在第一个</div>
之后,即:
</div>
<?php endif; ?>
</div>