How to set the color of web pages in php: first create two files, namely [changecolor.php] and [bgcolor.html]; then put them into the local server; then after starting, access them directly in the browser; finally Select a color and click the change button.
How to set web page color in php:
First, create two new files:
One: changecolor.php
Code:
<?php if(isset($_GET["cl"])){ $color = $_GET["cl"]; echo "<div style='text-align:center;width:100%'>".$color."</div>"; echo "<style>body{background-color:$color}</style>"; } ?>
One: bgcolor.html
Code:
<!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html" /> <meta name="author" content="jingyan.baidu.com" /> <title>背景颜色变更</title> </head> <body style="text-align:center;"> <form action="changecolor.php" method="get"> <select name="cl"> <option selected="true">Red</option> <option>Blue</option> <option>Pink</option> <option>Black</option> <option>Purple</option> </select> <input type="submit" value="chang"/> </form> </body> </html>
2. Put it into the local server. The editor uses APMServ5.2.6. After starting, access it directly in the browser (as shown in the picture)
Select a color and click the change button, and the effect will appear
Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of How to set web page color in php?. For more information, please follow other related articles on the PHP Chinese website!