我缺少一个无法找到的大括号。 解析错误显示在我的代码的末尾。我已经在此永远度过。我不太擅长PHP提示如何识别这些错误会有所帮助。在我的PHP代码中缺少大括号
<?php
/*Required Fields*/
require_once('websiteconfig.inc.php');
include (ABSOLUTE_PATH . 'class/person.class.php');
/*Starts the session for the person class*/
session_start();
/*FUNCTIONS*/
/*VERRIFY EMAIL ADDRESS AND PASSWORD AND MATCH IN SYSTEM*/
function validateLogin($emailaddress='', $password=''){
/*INITIALIZES VARIABLES*/
$email_key = '[email protected]';
$password_key = '1234';
$auth_match = 0;
/* CHECK FOR MATCH */
if($emailaddress == $email_key && $password == $password_key){
$auth_match = 1;
}
return $auth_match;
}
/*CLEAN FORM DATA*/
function sanitize($form_var) {
$clean_data = strtolower(trim($form_var));
return $clean_data;
}
/*PAGE VARIABLES*/
$auth_status = 0;
/*DETERMINE FORM HAS BEEN SUBMITTED*/
if(array_key_exists('submit', $_POST)) {
/*SANITIZE FORM DATA*/
$emailaddress = sanitize($_POST['emailaddress']);
$password = sanitize($_POST['password']);
/*VALIDATE FORM DATA*/
$auth_status = validateLogin($emailaddress, $password);
}
/*CONFIRM EACH FIELD WAS PROCESSED*/
//trigger login field exception
try{
if($emailaddress == '' || $password == ''){
throw new Exception('E-mail and password must be supplied to login. Please try again.');
}else{
/*VALIDATE FOR DATA*/
$auth_status = validateLogin($emailaddress, $password);
//trigger validation exception
try{
if(!isset($auth_status)) {
throw new Exception('Online Banking is not available at this time. Please try again later.');
}
}
// catch validation exception
catch(Exception $v) {
echo 'message: ' . $v->getMessage();
exit();
} //end catch
//This triggers the validation of authentication
try{
if ($auth_status == 0){
throw new Exception('Email address and or Password does not meet our records! Please try again.');
}elseif ($auth_status>0){
/*Member Session*/
$currentMember = new Person($auth_status);
/*Set Attributes*/
$currentMember->memberid = $auth_status;
$currentMember->firstname = 'Michael';
$currentMember->lastname = 'Crawley';
$currentMember->emailaddress = '[email protected]';
/*Serialize currentMember object*/
$_SESSION['currentMember'] = serialize($currentMember);
}
}// End try statment
//catch login field exception
catch(Exception $e) {
echo 'Message: ' . $e->getMessage();
exit();
}
?>
</div><div class="container" id="shadow">
<div>
<?php
include(ABSOLUTE_PATH . 'header.inc.php');
if($auth_status == 1){
/*AUTHENTICATION SUCCESS*/
echo '<h4>Welcome Back, Betty!</4>' . "\n\n";
echo '<ul>' . "\n";
echo "\t" . '<li><a href="' . APP_ROOT . 'onlinebanking" title="Online Banking">Online Banking</a></li>' . "\n\n";
echo '</ul>';
} elseif($auth_status == 0){
/*AUTHENTICATION FAILED*/
echo '<h4 class="error">Authentication Error!</h4>' . "\n\n";
echo '<p>Incorrect e-mail address and/or password submitted. Please try again.</p>';
}
?>
</div><!--End of main content-->
<?php
include(ABSOLUTE_PATH . 'footer.inc.php');
?>
</div>
如果您使用像记事本+ + +编辑器,它会自动匹配和颜色编码你的括号。我就是这么做的...... – 2012-03-10 16:29:35
你真的注意正确地缩进你的代码。在这里看到一些标准,选择一个并正确地遵循它。 http://en.wikipedia.org/wiki/Indent_style#K.26R_style – 2012-03-10 16:31:46
你最后的其他如果。你写了elseif – 2012-03-10 16:32:54