Jump to content

else/if problems


jayjaz

Recommended Posts

Post the code you are referring to and what the goal of it is. You can look into case / switch statement instead but it all depends on what the code is etc.

 

Without seeing the code we cannot effectively tell you the proper method or show you a better way to do the checks.

Link to comment
Share on other sites

What you might want to do is define an error class, or more simply something such as:

function CheckInput() {
   if(!isset($_GET['id'])){
      trigger_error('ID Not set');
   }
   if(strlen($_GET['id']) >= 30) { 
      trigger_error('ID too long');
   } //etc..
}

CheckInput();

 

Instead of:

if (isset($_GET['id'])) {
  if(!empty($_GET['id']) {
    if (strlen($_GET['id']) > 30) {
         die('ID too long');
    } else {
   $id = $_GET['id'];
  } else {
die('Please set ID');
//
} else {
//...
}..

 

As you can see, defining checks, or better yet error classes are cleaner and take less processing time.

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.