php - 如何让错误实际显示在我的 php 页面上?
问题描述
所以我决定在隔离期间我要练习一些编码,为 9 月份的 Web 开发课程做准备。所以我一直在尝试创建一个简单的注册页面。似乎其他一切都很好,但是当我测试错误是否有效时,它们实际上并没有出现。我似乎找不到任何问题。我有一个单独的 php 错误文件,然后是我的注册文件和服务器文件。
这是我的注册表单的代码
<!doctype html>
<html>
<body>
<div class=container>
<h1>Register</h1>
<p>Please fill in the form to create an account</p>
<form method="post" action="register.php">
<?php include ('errors.php'); ?>
<label>Email: </label>
<input type="text" name="email" value="<?php echo $username; ?>"><br>
<label>Username: </label>
<input type="text" name="username" value="<?php echo $email; ?>"><br>
<label>Password: </label>
<input type="Password" name="password"><br>
<label>Confirm Password: </label>
<input type="password" name="password2"><br>
<button class="registerbtn" type="submit" name="registerbtn">Register</button>
</form>
<p align="center">Already have an account? <a href="login.php">Sign in</a>.</p>
</div>
<?php
include 'footer.php'
?>
</body>
</html>
这是我的错误代码
<?php
$errors = array();
?>
<?php if (count($errors) > 0) : ?>
<div class="error">
<?php foreach ($errors as $error) : ?>
<p><?php echo $error ?></p>
<?php endforeach ?>
</div>
<?php endif ?>
解决方案
推荐阅读
- javafx - 使用 ObservableList 时如何避免 ConcurrentModificationException?
- python - 安装 lxml 时的异常
- r - 子集 data.table 基于键不是列表的元素
- elasticsearch - 是否可以在 ElasticSearch 中使用具有字母范围的范围聚合?
- python - Scikit-learn 自定义估计器“估计器的参数无效”错误
- python - (Python)如何使用 discord.py 从不和谐的消息中获取变量?
- python - 分类指标无法处理二进制和连续目标的混合 - Python 随机森林
- java - 如何分析以下算法复杂度
- python - Python中具有特定输入的数组拆分
- flutter - Flutter - 从 AppBar 返回上一页不会刷新页面,使用 Navigator.pop(context)