A simple example of color rotation

Source: Internet
Author: User
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 ";
}
?>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.