if else条件不在PHP中调用函数

if($process->g_User() && $process->g_Pass()){
         if($process->LdapConn()){
             if($process->LdapBind()){

                    return 'google';

             }else{
                procLogin();
         }
     }

     }

If my condition fails, it must call the procLogin() function but its not calling... the ProcLogin has just an echo...

if($process->g_User() && $process->g_Pass() && $process->LdapConn() 
   && process->LdapBind()) {
    return 'google';

When using this... it does not even call the google...

But in my latter code, at least it was calling...

My Requirement is... if the username and password is wrong, then it should fail regardless the connection is established or not.

Are you sure $process->LdapBind() is returning false and not $process->LdapConn()?

If I copy your example replacing the functions with true or false, it works just as expected when only $process->LdapBind() being false.

Maybe you want:

if($process->g_User() && $process->g_Pass()){
         if($process->LdapConn()  &&  $process->LdapBind()){
                    return 'google';
             }else{
                     procLogin();
         }
     }

     }

it will only trigger if both if($process->LdapConn()) AND if($process->LdapBind()) are true, are they?

EDIT: My Requirement is... if the username and password is wrong, then it should fail regardless the connection is established or not.

So, I take it that g_User() and g_Pass() validate each the username and password. As to what is 'fail' I'm guessing it's procLogin(). If 'fail' is return 'google', put the bodies the other way around.

If my assumptions are correct (which, again I cannot be sure of due to a sucky problem spec), then this is what you want

if($process->g_User() && $process->g_Pass()){
     if($process->LdapConn() && $process->LdapBind()){
        return 'google';
     }
} else {
     procLogin();
}

Never forget to indent correctly, and try to make your questions as clear as possible. For example, what is the condition you refer to is not clear at all... Now we all have to guess.

For example, if you want procLogin() to be called whenever a condition fails, and want to avoid repeating code you can take advantage of shortcircuiting to get the same behavior:

if($process->g_User() && $process->g_Pass() && $process->LdapConn() 
   && process->LdapBind()) {
    return 'google';
} else {
    procLogin();
}

Or, is it that you want procLogin() to be called if LdapConn() fails? Then you've misplaced the brackets:

if($process->g_User() && $process->g_Pass()){
     if($process->LdapConn()){
         if($process->LdapBind()){
            return 'google';
         }
     } else {
         procLogin();
     }
}

If you want procLogin() called if login fails:

if($process->g_User() && $process->g_Pass()){
 if($process->LdapConn()){
     if($process->LdapBind()){
            return 'google';
     }
 }


} else {
// Login has failed
procLogin();
 }