我想创建一个URL Shortener。网址缩短不工作|语法错误,文件意外结束
我有我的网络服务器中的所有文件,但现在,当我想简短的网址,它说我:
解析错误:语法错误,在/用户/ shrtml/WWW /公共意外的文件结束第36行的/submit.php
这是什么?这里是我的代码:
<?php
require_once "../include/config.php";
require_once "../include/ShortUrl.php";
if ($_SERVER["REQUEST_METHOD"] != "POST" || empty($_POST["url"])) {
header("Location: shorten.html");
exit;
}
try {
$pdo = new PDO(DB_PDODRIVER . ":host=" . DB_HOST . ";dbname=" . DB_DATABASE,
DB_USERNAME, DB_PASSWORD);
}
catch (\PDOException $e) {
header("Location: error.html");
exit;
}
$shortUrl = new ShortUrl($pdo);
try {
$code = $shortUrl->urlToShortCode($_POST["url"]);
}
catch (\Exception $e) {
header("Location: error.html");
exit;
}
$url = SHORTURL_PREFIX . $code;
echo <<<ENDHTML
<html>
<head>
<title>URL Shortener</title>
</head>
<body>
<p><strong>Short URL:</strong> <a href="$url">$url</a></p>
</body>
</html>
ENDHTML; <<< This is line 34. End of file.
之后将PHP结束标记
?>
放在新行上将文本粘贴一行错误信息太难了吗?如果你只是复制它,你甚至可以先尝试*搜索它。 – GolezTrol好的。这是ErROR – logtainment
@GolezTrol |你可以帮我吗? – logtainment