0

hello....

it could be interesting.......my frnd asked a question to me...on if else condition.
for suppose...

<?php
if(Condition)
{
echo "hello";
}
else
{
echo "world";
}

it is the question. she asked me how to write condition for print hello world.

6
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by firstPerson
0

Your setup will either echo "hello" or echo "world", but the way it's set up it will never output "hello world." So what was the question?

Edited by CFROG: n/a

0

What ever you are asking may happen using switch..case statement without using break

switch ($variable)
{
case '1':
      print "hello";
      //break;
case '2':
      print "world";
}

Edited by urtrivedi: n/a

0
switch ($variable)
{
case '1':
      print "hello";
case '2':
      print "world";
case default:
      print "hello world";
}

if you give 1: prints hello world 2: world apart from these always print "hello world"

0

if you give 1: prints hello world 2: world apart from these always print "hello world"

rajarajan as you have not used break statement, your code will give following output
on 1) helloworldhello world
on 2) worldhello world
else) hello world

0

I cannot understand your question Muralikalpana

if condition and else condition is there....i want to display
hello world.

<?
if(Condition)
{
echo "hello";
}
else
{
echo "world";
}
?>

then my frnd asked to me what the condition should write in if condition to display "hello world".

0

Really confused. What is your expectation? if you want "hello world" make it directly for the condition you want. But here what is your condition?

Edited by rajarajan07: n/a

0

if condition and else condition is there....i want to display
hello world.

<?
if(Condition)
{
echo "hello";
}
else
{
echo "world";
}
?>

then my frnd asked to me what the condition should write in if condition to display "hello world".

With that code its not possible. Only one of the echo will execute because if(condition)
has only 2 answers, true or false. If its true then echo "hello" else "world". As
suggested my previous post, you might try compound boolean expression.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.