I want to use page url eg. example.com/randomimage/
in HTML <img>
tag to display random images.
Is that possible with PHP?
I can change /randomimage/
page code via page-randomimage.php
file.
CodePudding user response:
You can't return an HTML page from your PHP script for that to work. In HTML, <img>
tags are designed to load image content, not HTML content.
Instead you could program page-randomimpage.php
to redirect to a random image URL. Something like this random redirect script but with image URLs in it rather than website URLs. The redirects should be "302 Temporary" type redirects so that the redirector result is not cached by browsers.