Home  >  Article  >  Backend Development  >  How to set web page color in php?

How to set web page color in php?

coldplay.xixi
coldplay.xixiOriginal
2020-07-13 10:26:144018browse

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?

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=&#39;text-align:center;width:100%&#39;>".$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

How to set web page color in php?

How to set web page color in php?

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!

Statement:
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