php - 解析错误:语法错误,第 48 行 php 中的文件意外结束
问题描述
下午\我很难确定代码的错误,我需要帮助。每次我执行代码时都会出现一个错误,我无法确定错误本身
<?php
include('functions.php');
if (!isLoggedIn()) {
$_SESSION['msg'] = "You must log in first";
header('location: login.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="header">
<h2>Home Page</h2>
</div>
<div class="content">
<!-- notification message -->
<?php if (isset($_SESSION['success'])) : ?>
<div class="error success" >
<h3>
<?php
echo $_SESSION['success'];
unset($_SESSION['success']);
?>
</h3>
</div>
<?php endif ?>
<!-- logged in user information -->
<div class="profile_info">
<img src="images/user_profile.png" >
<div>
<?php if (isset($_SESSION['user'])) : ?>
<strong><?php echo $_SESSION['user']['username']; ?></strong>
<small>
<i style="color: #888;">(<?php echo ucfirst($_SESSION['user']['user_type']); ?>)</i>
<br>
<a href="index.php?logout='1'" style="color: red;">logout</a>
</small>
<?php endif ?>
</div>
</div>
</div>
</body>
</html>
解决方案
您在代码的第一行中缺少右括号:
<?php
include('functions.php');
if (!isLoggedIn()) {
$_SESSION['msg'] = "You must log in first";
header('location: login.php');
} // <- Here is the mistake
?>
推荐阅读
- ios - 在 Xcode 10.2.1 中使用 AudioKit Playground
- excel - VBA 中的搜索程序
- python - 如何将数据框转换为数据透视表
- android - 使用 android nytimes Store 库获取数据时遇到问题
- reactjs - 有没有办法动态创建 React 组件
- machine-learning - 在 Keras 中强制对称
- tableview - 如何在 TornadoFX 中隐藏表格视图的标题?
- docker - 如何在 docker 中为 cmake msvc build 设置编译选项?
- c - GTK 字符数与字节索引
- google-cloud-firestore - Firestore 规则:由于(推荐的)对 request.auth.uid 的单一检查,创建用户的规则通知不安全