Computing.Net > Forums > Web Development > PHP Break from If statement

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP Break from If statement

Reply to Message Icon

Name: mikedfrank
Date: January 10, 2005 at 16:45:05 Pacific
OS: Win98/XP
CPU/Ram: 512
Comment:

Does anybody know if it's possible to break out of an if statement? Thanks for your help.



Sponsored Link
Ads by Google

Response Number 1
Name: Laler
Date: January 10, 2005 at 19:07:59 Pacific
Reply:

can you describe why do you want to break the if statement?

if it's about many if, can it be done by using elseif?

^o^
are you in Asia? do you watch Animax Asia? Please Vote


0

Response Number 2
Name: mikedfrank
Date: January 10, 2005 at 21:10:40 Pacific
Reply:

It's a login script, with "is valid user check" nested in another required IF. If the user is invalid, display the page code at the bottom of this script, outside of the php code. No elses can be used.


0

Response Number 3
Name: Laler
Date: January 11, 2005 at 02:40:07 Pacific
Reply:

ok

cmiiw but as far as I know we can't break the IF... we can however:

if (notauthenticated){
header ("Location: badlogin.php");
exit();
}

to force redirection and putting exit() to make sure the current script ends... I use this quite often...

in your case, if it's too complicated to put the badlogin into another page, maybe you can use something like this:

if (something){

if (notauthenticated){
$badlogin = TRUE;
}

}


//and enclose the badlogin codes at the bottom with another if

if (isset ($badlogin)) and ($badlogin == TRUE)){
?>

<!-- html outside php goes here -->

<?php
}
?>

did that make sense =D


^o^
are you in Asia? do you watch Animax Asia? Please Vote


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: PHP Break from If statement

If statement code in PHP www.computing.net/answers/webdevel/if-statement-code-in-php/2152.html

PHP If Statements www.computing.net/answers/webdevel/php-if-statements/2787.html

line break from database results www.computing.net/answers/webdevel/line-break-from-database-results/641.html