Senin, 06 April 2009

Random Background Color With PHP

The PHP random function (rand()) can be use to random webpage background color. Use this syntax on HTML body


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body bgcolor="<?php echo"#".rand(996699,999999); ?>">
</body>
</html>


Save this code in filetipe of PHP in your server. Then you can check what happen in your browser background color.

The 996699 is the first input color and 999999 is the second input color that use in rand() function.

You can change the color range by 000000 (black) to FFFFFF (white).
Related Post: