I have included php in html to change the background image according to some variables. Thus i am calling img-set() function in body tag. The function is working fine. But the html code breaks after the function has been run. I think it’s some syntax problem not able to it figure out.
<body style="background:url(images/<?php $obj->set_img();?>); -webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cover;">
The output in source code of web browser looks like:
<body style="background:url(images/music7.jpg
This break after displaying image name. Why so ??
Here, is the set_img() function
function set_img()
{
$ctr = date("d");
$arr7 = array("7","18","29");
$status = 0;
foreach($arr7 as $value){
if($ctr == $value){
echo "music7.jpg";
$status = 7;
}}
if(!$status) echo "music1.jpg";
}
Use
<?php set_img();?>not<?php $obj->set_img();?>