I’m just learning php, To practice i want to try and make a php function that can generate CSS3 gradients easily in a document.
I am running into HTTP Error 500. here’s the code :
<?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>
Any help is much appreciated.
You can’t put double quotes inside double quotes. You can either escape them (like the other answers say) or use single quotes.
Also, you need quotes when calling
cgrad.