Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

PHP script to change images on page refresh

In this tutorial i am going to show you how to change images dynamic on each time you refresh your page.
There is simple PHP script to get it working.

srand( microtime() * 1000000 );
$num = rand(1,2);
switch($num)
{
     case 1: 
     $imageName = "image1.jpg";
     break;
     case 2: 
     $imageName = "image2.jpg";
     break;
}

echo "<img src=images/".$imageName." />";

Please support us, Like us on Facebook.

0 comments:

Post a Comment

 

Copyright @ 2017 HKBlog.