Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

annas Group Title

3rd tutorial on php: contents: 1. if statement 2. if-else statement 3. if-elseif statement

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    'if' statement is a decision making statement. Its syntax is: if(condition){ //block to be executed } In php how we use if statement lets have a look at it by a program. <?php $name = 'bob'; if($name=='bob'){ echo 'Hello bob'; } ?>

    • 2 years ago
  2. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    output: Hello bob //because variable name == bob let see another example where the condition is false: <?php $name = 'bob'; if($name=='Mike'){ echo 'Hello bob'; } ?> in this case nothing will be displayed because the condition is fails.

    • 2 years ago
  3. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    Now let move to words our next topic i.e. if-else statement It is same as if statement except it has an else block so that when the condition is false the control will be transfer to the else part. Let have an example: <?php $name = 'Mike'; if($name=='Mike'){ echo 'Hello Mike'; } else { echo 'Dear user you are not Mike'; } ?> output: Hello Mike because condition is true. Now, let see another example where condition is not true. <?php $name = 'bob'; if($name=='Mike'){ echo 'Hello Mike'; } else { echo 'Dear user you are not Mike'; //this line is executed this time } ?> output: Dear user you are not Mike

    • 2 years ago
  4. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    Now lets move towards the next content i.e. if-elseif. In if-elseif multiple conditions and block are available. lets see an example: <?php $name = 'bob'; if($name=='Mike'){ echo 'Hello Mike'; } elseif($name=='bob') { echo 'Hello Bob'; } else { echo 'You are neither Bob nor Mike'; } ?> output: Hello Bob elseif, as its name suggests, is a combination of if and else. Like else, it extends an if statement to execute a different statement in case the original if expression evaluates to FALSE. However, unlike else, it will execute that alternative expression only if the elseif conditional expression evaluates to TRUE.

    • 2 years ago
  5. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    Well thats it for this tutorial. I hope this tutorial will be interesting and helpful for you guys. Good luck. :)

    • 2 years ago
  6. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    for those who join the tutorial now can also see the previous tutorials. 1. http://openstudy.com/study#/updates/4ffa87a8e4b058f8b7666f25 2. http://openstudy.com/study#/updates/4ffb14c9e4b058f8b766d273

    • 2 years ago
  7. malihe Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    fantastic

    • 2 years ago
  8. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    thank you

    • 2 years ago
  9. annas Group Title
    Best Response
    You've already chosen the best response.
    Medals 8

    @agdgdgdgwngo what do you think about the tutorials ???

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.