$newString = 0 [COLOR="Red"]?[/COLOR] rawurlencode($serverName) : rawurlencode($IDN->decode($myString));
I have the code above.
I like to know about the meaning of the Question Mark of it.
and
I like to know where of the php Manual I can study about “?”
It’s a shorthand IF.
IFcond ? True(Then) : False(Else);
StarLion:
It’s a shorthand I F.
The code below works fine.
<?php
$number=1;
[COLOR="Red"]IF[/COLOR] ($number==1) echo "yes";
?>
I substitue “IF” the shorthand of it like the following.
But it produces a php error.
<?php
$number=1;
[COLOR="Red"]?[/COLOR] ($number==1) echo "yes";
?>
Could you give me a simple code which contains the short hand “? ”, please ?
or
Where in php manual can I study of “? ” ?
jameso
November 9, 2010, 2:10am
4
The ? is a shorthand notation is for an IF ELSE statement, trying to use it for a shorthand IF notation is not possible so you would have to stick with
if ($number == 1) echo "yes";
The only way you can get your statement to work is by using
echo ($number == 1) ? "yes" : "";
A = B ? C : D
is a short way of saying
if (B) A = C;
else A = D;