I’m trying to use a parameter in the URL to get a Image Path, then display the image on the Website. I have tried this, but it doesn’t work.
URL is like: https://DOMAIN/file.php?logo=https://DOMAIN/IMG/image.png
<div class="container"> <div class="logo"> <?php $logo = $_GET['logo']; ?> <img src="$logo"> </div> </div>
I have also tried the (No quotation marks but that didn’t work either.
Thanks!
Advertisement
Answer
Since $logo
is a PHP variable, so if you don’t call it in side <?php ?>
then it will literally print out <img src="$logo">
in the HTML element.
Code:
<div class="container"> <div class="logo"> <?php $logo = $_GET['logo']; ?> <img src="<?= $logo ?>"> </div> </div>
OR:
<div class="container"> <div class="logo"> <?php $logo = $_GET['logo']; ?> <img src="<?php echo $logo; ?>"> </div> </div>