Giovo wrote:
Can someone tell me how this works. I never understood those macho echo statements. Can someone show me the light?
echo "If this is correct print this ".($result ? "" : "not correct")."Else print this code that drives me crazy\n";
I don't get it. What does that mean:
.($result ? "" : "not correct")."
Any idea? Thanx.
I'm not sure if I got your question, anyway
. means cat the following string
($result ? "" : "not correct") is a conditional expression in the form
a?b:c
meaning if (a) value is b else value is c
evaluation of $result as boolean maybe a sort of an havoc because it (the variable) could be a real boolean, with trivial meaning, a string with meaning "is empty or not", a number with meaning "is non zero", an array or object with other meaning and so on.
The equivalent code is
if ($result)
$@!#$ = "";
else
$@!#$ = "not correct";
echo "If this is correct print this $@!#$ Else print this code that drives me crazy\n";