Php 语法错误,第32行出现意外的T_PUBLIC

Php 语法错误,第32行出现意外的T_PUBLIC,php,Php,我得到了这个代码的错误。它说语法错误,在第32行的C:\wamp\www\openarc\application\controllers\login.php中出现意外的T\u PUBLIC。我认为缺少一个花括号。但是在哪里找不到它。请帮帮我 <?php /** * This class use to registered users login to the site and logout */ class Login extends CI_Controller{ /*

我得到了这个代码的错误。它说语法错误,在第32行的C:\wamp\www\openarc\application\controllers\login.php中出现意外的T\u PUBLIC。我认为缺少一个花括号。但是在哪里找不到它。请帮帮我

<?php

/**
 * This class use to registered users login to the site and logout 
 */
class Login extends CI_Controller{


    /*load the login page*/
    function index($pass_details=false)
    {
        //if user is already logged in restrict login page to user
        if($this->isLoggedin())
        {
            redirect('/');
        }
        //if user is not logged in
        else
        {
            //if login failed pass $pass_details message to login view
            if(isset($pass_details))
            {
                $login_messeage['loginErrorMessage'] = $pass_details;
               // $login_messeage['userName']          = $pass_details['user_name'];
            }
            $login_messeage['page_id'] = "login";
            //pass error message and user_name to view and show login page
            $this->load->view("template",$login_messeage);
        }
    }
    }
    /*take the login form values and do the back end validation and send those values to the Login_model*/
    public function user_login()
    {

        if(!$this->isLoggedin())
        {

            $username = $this->input->post('lg_username');
            $password = $this->input->post('lg_password');
            $url      = $this->input->post('hidden_url');

            //load the login_model 
            $this->load->model('Login_model');

            //create an array and pass username and password
            $user_login_details =array(

                'username' => $username,
                'password' => sha1($password),

            );

            //pass $user_login_details array to the Login_model get_specific_record function 
            $result  = $this->Login_model->get_specific_record($user_login_details);

            //get executed result counter of num_rows into $numrows variable
            $numrows = $result->num_rows();

            //get database values to variable into variables from executed result

            if($numrows>0)
            {
                foreach ($result->result() as $row)
                {
                   $uname        = $row->username;
                   $upassword    = $row->password;
                   $userid       = $row->login_id;
                   $usertype     = $row->user_type;
                   $userrefid    = $row->reference_id;
                }
                if($usertype == 'Ad')
                { //echo "ggg";exit();
                    //check executed result num_rows() counter is grater than 0 

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     =>$uname,
                         'userType'     =>$usertype,
                         'refId'        =>$userrefid,
                         'login_status' => true
                    );

                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('adminpanel');

                }
                else if ($usertype == 'Op') {
                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                    );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('Production');
                }
                else if($usertype == 'C')
                {

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userid'       => $userid, 
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                     );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    $cartSessionArray = array(
                         'user_id'    => $userid, 
                         'status'    => 'A' 
                    );

                    $this->load->model('Cart_model');                           
                    $cart_result  = $this->Cart_model->get_all_cart_data($cartSessionArray);

                    $cart_numrows = $cart_result->num_rows();
                    if($cart_numrows >0)
                    {
                        foreach ($cart_result->result() as $cart_row)
                        {
                            $cart_id = $cart_row->id;
                            $cart_name = $cart_row->name;
                            $cart_price = $cart_row->price;
                            $cart_qty = $cart_row->qty;

                            $insert_cart = array(
                                                'id' => $cart_id,
                                                'name' => $cart_name,
                                                'price' => $cart_price,
                                                'qty' => $cart_qty

                                                 );
                               $res = $this->cart->insert($insert_cart);


                           }

                           if($res)
                           {
                                if ($url == 'index') 
                                {
                                       redirect('place_order');
                                }
                                else 
                                {
                                    redirect($url);
                                }
                              ;//    redirect('/products');
                           }

                            else {

                               if ($url == 'index') 
                                {
                                       redirect('place_order');
                                }
                                else 
                                {
                                    redirect($url);
                                }

                            }
                    }
                    else 
                    {
                         redirect($url);
                    }  
                }
                else if($usertype == 'Ma')
                {

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userid'       => $userid, 
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                     );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('management/monthly_order_count');


                }   

            }
            else
            {
                $pass_details     =  "<div class='alert alert-error'>Username or password is Wrong</div>"; 
                $this->index($pass_details);
            }

        }

        else
        {
            redirect('/');
        }

    }


    /*logout the loged user*/
    public function logout()
    {
        if($this->isLoggedin())
        {
            //unset session data for user logout
            $this->session->sess_destroy();

            //redirect to the home page
            redirect('/');
        }

    }
}

}
?>
打字错误:


由于您有一个额外的括号,您的类定义会提前终止,使public无效,因为它仅在类定义中有效。

您正在关闭第31行的类定义

...
28        $this->load->view("template",$login_messeage);
29      } // end if
30    } // end function index
31  } // misplaced end class definition

去掉第31行。

当我删除它时,会出现语法错误,第224行出现意外的“}”,您需要学习基本调试。如果您甚至无法在某处找到一个游离的/额外的{或},那么您就不应该进行编码。当再次删除它时,请在第12thanx行调用未定义的方法Login::isLoggedin。我把它拿走了。但是现在在第12行调用未定义的方法Login::isLoggedin。如果你能帮上忙,那将是一个很大的帮助,因为我是这个时代的新手
...
28        $this->load->view("template",$login_messeage);
29      } // end if
30    } // end function index
31  } // misplaced end class definition