Home > Backend Development > PHP Tutorial > A simple example of color rotation_PHP tutorial

A simple example of color rotation_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 16:02:11
Original
866 people have browsed it

A simple example of color rotation, using the ternary operator to make the program concise.
We have seen on the website that the background color of some table cells changes every other row. In fact, this can be achieved with the following small piece of code: $color=(($coloralter++ %2)? "e0e0e0": "e8e8e8"), that is, by accumulating variables and taking the remainder 2, using the ternary operator to obtain two different color values.
An example is as follows:


test






for ($i=0;$i<5;$i++) {
$color = (( $coloralternator++ %2) ? "e0e0e0" : "ff6666");
echo "}
?>
Hello everyone




www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316593.htmlTechArticleA simple example of color rotation, using the ternary operator to make the program concise. We have seen on the website that the background color of some table cells changes every other row. In fact, use the following method...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why does it still jump after returning false?
From 1970-01-01 08:00:00
0
0
0
Optimize table indexes in MySQL
From 1970-01-01 08:00:00
0
0
0
Why can't I install it?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template