본문 바로가기

웹개발/CSS

[CSS,PHP] PHP로 CSS 출력하기

::::::::::::::
html.php
::::::::::::::
<html><head>
<link rel="stylesheet" href="css.php?id=<?=$_GET['id'];?>" type="text/css">
</head>
<body>
<p class=line>
Line Line Line Line Line Line Line Line Line Line Line Line Line Line Line Line
</p>
</body></html>
::::::::::::::
css.php
::::::::::::::
<?php
header( "Content-type: text/css");

switch( $_GET['id']) {
case 'A': echo "p.line { border: 1px solid green; }"; break;
case 'B': echo "p.line { border: 1px dotted blue; }"; break;
case 'C':
default:  echo "p.line { border: 2px solid cyan; }"; break;
}