A little stuck with something

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ahevans

    A little stuck with something

    HI,

    I have the following scenario

    if (isset($area)) {

    if ($area === 'green') {

    if (isset($task)) {

    if ($task === 'do') {
    //do something
    } else {
    echo "message 4";
    }
    } else {
    echo "message 3";
    }
    } else {
    echo "message 2";
    }

    } else {
    echo "message 1";
    }

    if i use the url 'index.php?area =green', I am given message 4 and not
    3, why is this?
  • Travis Font

    #2
    Re: A little stuck with something

    $task === 'do'

    just "==" should do

    Comment

    • TekWiz

      #3
      Re: A little stuck with something

      ahevans wrote:[color=blue]
      > HI,
      >
      > I have the following scenario
      >
      > if (isset($area)) {
      >
      > if ($area === 'green') {
      >
      > if (isset($task)) {
      >
      > if ($task === 'do') {
      > //do something
      > } else {
      > echo "message 4";
      > }
      > } else {
      > echo "message 3";
      > }
      > } else {
      > echo "message 2";
      > }
      >
      > } else {
      > echo "message 1";
      > }
      >
      > if i use the url 'index.php?area =green', I am given message 4 and not
      > 3, why is this?[/color]

      Not sure. Check the rest of your code for $task?? if you've set $task
      to an empty string (ie. "") then, I believe, it is still set.

      However, take a look at your coding standards. Your code is quite
      difficult to read. eg. line spacing, more understandable indents, etc.

      Here's an example of something more understandable:

      if (isset($area)) {
      if ($area === 'green') {
      if (isset($task)) {
      if ($task === 'do') {
      //do something
      }
      else echo "message 4";
      }
      else echo "message 3";
      }
      else echo "message 2";
      }
      else echo "message 1";


      --TekWiz

      Comment

      Working...