if ($x > $y)
$mycolor="red";
else
$mycolor="green";
echo "$myvalue ";
It is just a if/else condition.
I have just discovered that there is a simpler method to do so. This is by the Ternary conditioning ?: code.
The example can be made simpler as follows
$mycolor= ($x > $y") ? "red" : "green";
echo "$myvalue ";
It sure makes thing easier and less coding.
No comments:
Post a Comment