用PHP其实也可以实现简单的“换肤”,其实就是换CSS(当然不可能做到象asp.net 2.0那样厉害拉),
但有时也可以凑合着使用,先要准备几个CSS
style/default.css
body { font-family: arial, verdana; font-size: small; margin: 0px; }
.box { background: red; }
.box-title { text-align: center; color: white; font-weight: bold; }
.box-content { background: white; font-size: xx-small; padding:10px;}
.menu { margin: 5px; }
.menu-active { margin: 2px; padding:5px; background: black; }
.menu-active a { text-decoration: none; color: white; font-weight: bold; }
.menu-inactive { margin: 2px; padding:5px; background: #ccc; }
.menu-inactive a { text-decoration: none; }
styles/black_and_white.css
body { font-family: arial, verdana; font-size: small; margin: 0px; }
.box { background: #eee; border: 1px solid black; }
.box-title { background: white; text-align: center; font-weight: bold; }
.box-content { background: white; font-size: xx-small; padding:10px;}
.menu { margin: 5px; }
.menu-active { margin: 2px; padding:5px; background: black; }
.menu-active a { text-decoration: none; color: white; font-weight: bold; }
.menu-inactive { margin: 2px; padding:5px; background: #ccc; }
.menu-inactive a { text-decoration: none; }
index.php
<html>
<head>
<?php
$style = "default";
if ( $_GET["style"] )
$style = $_GET["style"];
$files = array( );
$dh = opendir( "styles" );
while( $file = @readdir( $dh ) )
{
if( preg_match( "/[.]css$/", $file ) )
{
$file = preg_replace( "/[.]css$/", "", $file );
$files []= $file;
}
}
?>
<style type="text/css" media="all">@import url(styles/<?php echo($style); ?>.
css);</style>
</head>
<body>
<table width="800">
<tr>
<td width="200" class="menu" valign="top">
<div class="menu-active"><a href="home.php">Home</a></div>
<div class="menu-inactive"><a href="faq.php">FAQ</a></div>
<div class="menu-inactive"><a href="contact.php">Contact</a></div>
</td>
<td width="600" valign="top">
<table class="box">
<tr>
<td class="box-title">
Important information
</td>
</tr>
<tr>
<td class="box-content">
Lots of information about important events and
stuff.
</td>
</tr>
</table>
</td>
</tr>
</table>
<form>
Style: <select name="style">
<?php foreach( $files as $file ) { ?>
<option value="<?php echo($file); ?>"
<?php echo( $file == $style ? "selected" : "" ); ?>
><?php echo($file); ?></option>
<?php } ?>
</select>
<input type="submit" value="Select" />
</form>
</body>
</html>