我是PHP新手,我面臨語法錯誤。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"]);
}
?>
錯誤:
Parse error: syntax error, unexpected '||' (T_BOOLEAN_OR), expecting ')' in /home/jharvard/vhosts/localhost/html/register.php on line 9
我很新的PHP,這是可能的這段代碼有多個錯誤。 作爲參考,道歉只是簡單地渲染一個抱歉的消息以及額外的輸入,渲染只是一個簡化渲染過程的模板。
'如果(空($ _ POST [ '名']))'你有一個額外的括號封閉的if語句 – Pankrates 2013-04-10 14:47:53
感謝,定了! – 2013-04-10 14:49:45
PHP錯誤幾乎總會給你足夠的信息來發現問題。如果你學會閱讀錯誤,你永遠不會有語法問題。 – Narek 2013-04-10 14:50:01