我只是在学习 php,为了练习,我想尝试制作一个可以在文档中轻松生成 CSS3 渐变的 php 函数。
我遇到了 HTTP 错误 500。这是代码:
<?php
function cgrad($c1,$c2,$applyto)
{
echo
"<style type="text/css">
$applyto {
background-image: -ms-linear-gradient(top, $c1 0%, $c2 100%);
background-image: -moz-linear-gradient(top, $c1 0%, $c2 100%);
background-image: -o-linear-gradient(top, $c1 0%, $c2 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, $c1), color-stop(1, $c2));
background-image: -webkit-linear-gradient(top, $c1 0%, $c2 100%);
background-image: linear-gradient(to bottom, $c1 0%, $c2 100%);
height : 100%;
width : 100%;}
</style>";
};
?>
<html>
<head>
<?php
cgrad(#FFFFFF,#000000,body);
?>
</head>
<body>
testing
</body>
</html>
任何帮助深表感谢。