Yes, but I can only get what you want if I place the code after the relevant HTML. You can echo scripts...for example, this will work:
document.getElementById('footer').innerHTML = '$myVar';
";
?> // You will see Hello in the footer
but this will not work:
document.getElementById('footer').innerHTML = '$myVar';
";
?>
// You will see Hey in the footer
As a side note, these other functions/methods will work too:
$myVar = 'Hi';
echo "";//Alerts 'Hi'
$myVar = 'home.php';
echo "";//Takes you to home.php
$myVar = 'hi';
echo "";//calls myFunction with argument $myVar