写给自己备忘的...

changStyle.php:

1 $color = $_GET["color"];
2 setcookie('color',$color,time()+31536000);
3 header("location:".$_SERVER['HTTP_REFERER']);

index.php:

 1 <?php 
 2 if(isset($_COOKIE['color'])){
 3     $color = $_COOKIE['color'];
 4         //通过选择得到的当前样式
 5     $style = "../webdoc/css/service/".$color."/style.css";
 6 }else{
 7         //页面加载后默认的样式
 8     $style = "../webdoc/css/service/blue/style.css";
 9 }
10 ?>

index.php中的head部分:

1 <link rel="stylesheet" type="text/css" href="<?php echo $style ?>" />

index.php中的html部分:

1 <href="changeStyle.php?color=blue">蓝色</a>
2 <href="changeStyle.php?color=gray">灰色</a>
3 <href="changeStyle.php?color=red">红色</a>
4 <href="changeStyle.php?color=green">绿色</a>

OK,搞定,收工!
PHP实现页面样式切换

相关文章:

  • 2022-12-23
  • 2021-07-10
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2022-02-13
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案