How to put a PhP variable inside an img src? -
i'm trying put image in website, need src php variable, , console error "path couldn't found"
setting image variable
<?php $rand = rand(1,4); $image = "aff"; switch ($rand) { case 1: $image = "images/correr.jpg"; break; case 2: $image = "images/banhammer.png"; break; case 3: $image = "images/ender1.png"; break; case 4: $image = "images/ender2.png"; break; default: break; } ?>
trying retrieve it
<img src="<?php $image ?>" />
error message
file:///c:/users/leonardo/desktop/games/m/site/%3c?php%20$image%20?%3e failed load resource: net::err_file_not_found
you need echo variable:
<img src="<?php echo $image; ?>">
also make sure php being executed? in file .php
extension?
Comments
Post a Comment