Jump to content

[SOLVED] Break out of If Statement


maxudaskin

Recommended Posts

Is it possible to break out of an if statement? I cannot use die because it finishes the execution of the whole page. How can I exit from one if statement?

 

Can you show an example of why you would need to?

Link to comment
Share on other sites

does seem alittle strange breaking out of an if.

 

you use a if to test if something is correct. then it does something. if something isn't correct, then you use a else. or. you just use the if by itself.

 

so if you dont want the script to die. The if should return false and never execute. hence, why would you need to break the if?

Link to comment
Share on other sites

<?php
if(isset($_POST['login'])){ // If Login Form was Sent
  if(empty($_POST['user'])){
     echo "You have not provided a username.";
  }
  if(empty($_POST['pass'])){
     echo "You have not provided a password.";
  }
  // If user or pass are empty, exit if statement
   // More code including if statements
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.