A simple example of color rotation, using a ternary operator, makes the program concise. We once saw on the website that the background color of some table cells changes across rows. In fact, we can use the following small piece of code: $ color ($ coloralter ++ % 2 )? & Quot; e0e0e0 & quot;: & quot; e8e8eSyntaxHigh
A simple example of color rotation, using a ternary operator, makes the program concise.
We once saw on the website that the background color of some table cells changes across rows. In fact, we can use the following small piece of code: $ color = ($ coloralter ++ % 2 )? "E0e0e0": "e8e8e8"), that is, by accumulating the variable and taking the remainder of 2, two different color values are obtained using the ternary operator.
Example:
Test
For ($ I = 0; $ I <5; $ I ++ ){
$ Color = ($ coloralternator ++ % 2 )? "E0e0e0": "ff6666 ");
Echo "Hello everyone ";
}
?>