I am attempting to pull a random image from a folder using PHP. I am very new to PHP and understand the basics, but had to look up code to do this. The following code is the simplest of what I found:
<img src="commonImages/homepage/site_[php]<? php echo rand(1,4); ?>[/php].jpg" width="400px" height="400px"/>
I cannot get it to return the image. There are 4 images and they are all named “site_#.jpg.” I cannot figure out why I can’t get this to work. I have attempted to use longer php coding with named variables echoing back things like “+site_+$randnum+.jpg”, but none of it seems to work. Am I doing something wrong? Thanks in advance!