PHP Break from If statement
|
Original Message
|
Name: mikedfrank
Date: January 10, 2005 at 16:45:05 Pacific
Subject: PHP Break from If statementOS: Win98/XPCPU/Ram: 512 |
Comment: Does anybody know if it's possible to break out of an if statement? Thanks for your help.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Laler
Date: January 10, 2005 at 19:07:59 Pacific
Subject: PHP Break from If statement |
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: mikedfrank
Date: January 10, 2005 at 21:10:40 Pacific
Subject: PHP Break from If statement |
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Laler
Date: January 11, 2005 at 02:40:07 Pacific
Subject: PHP Break from If statement |
Reply: (edit)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
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: