I have a echo call outputting some HTML code, some of this code include a css, in this css i'm trying to execute some php code.
variable set before echo
$bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' );
$i = rand(0, count($bg)-1);
$selectedBg = "$bg[$i]";
Then in the echo:
echo'
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<link type="image/x-icon" href="test.ico" rel="shortcut icon" />
<style>
html {background:#000;
background: url("<?php echo $selectedBg; ?>") no-repeat fixed 0% 0% / cover #000;}
i've tried several of ways to run the php inside the echo but i fail, if i put the php inside '' tags page will not load, what am i doing wrong here or is it impossible to echo new php code inside a php echo?
Thank you!