So, Well I was wondering, Is it possible to do this;
if($pro == true)
echo "He's";
echo "a";
echo "pro.";
Or do I need to use { } ? Thanks.
It depends on your intentions. With your code
if($pro == true)
echo "He's";
echo "a";
echo "pro.";
The result (if $pro is true) will be:
He'sapro.
If $pro is false it will be
apro.
If you don't want that output on false, please add the braces.
if($pro == true) {
echo "He's ";
echo "a ";
echo "pro.";
}
questioner I think it's simple if else structure we all know from inception of coding.
After executing first line after IF block without bracket( '{' ), rest will be executed as it is.
if(1==1)
echo "Hi!";
echo "How are you?";So the output of the above is: Hi! How are you? Both lines are returned.
Now if you want to separate out output then enclose else block,
if(1==1) { echo "Hi!"; } else { echo "How are you?"; }
So the output of the above is: Hi!
#SpongePablo has truly explained well.