利用static实现表格的颜色隔行显示
我们用PHP从数据库查询数据,并将结果输出到浏览器上,如果结果有很多行,表格的bgcolor如果全是单色的,浏览者会感觉不太舒服。那麽怎样做使表格各行的颜色不同呢?
请看下面:
function getcolor()
{
static $colorvalue;//定义一个静态变量
if($colorvalue=="#ffffff")
$colorvalue="#000000";
else $colorvalue="#ffffff";
return($colorvalue);
}
print("
$i | n");
说明:
此程序中定义了一个静态变量static $colorvalue意思是在函数调用结束后,
此变量$colorvalue还保留值,没有消失。当再次调用getcolor()函数时,变量$colorvalue的值是上次函数调用结束时$colorvalue的值。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
