我是PHP的新手,我面临语法错误.
码:
<?php
// configuration
require("../includes/config.php");
// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST['username'])) || empty($_POST['password'] || $_POST['password'] != $_POST['confirmation']){
apologize('You did something wrong!');
}
}
else
{
// else render form
render("register_form.php", ["title" => "Register"]);
}
?>
Run Code Online (Sandbox Code Playgroud)
错误:
解析错误:语法错误,意外'||' (T_BOOLEAN_OR),在第9行的/home/jharvard/vhosts/localhost/html/register.php中期待')'
我是PHP的新手,这个代码有可能存在多个错误.作为参考,道歉只是简单地呈现一个抱歉消息以及其他输入,而渲染只是一个用模板简化渲染过程的功能.
更改:
if(empty($_POST['username'])) || empty($_POST['password'] || $_POST['password'] != $_POST['confirmation']){
Run Code Online (Sandbox Code Playgroud)
至:
if(empty($_POST['username']) || empty($_POST['password']) || $_POST['password'] != $_POST['confirmation']){
^ ^
Run Code Online (Sandbox Code Playgroud)