Random Image Generator In PHP
Here is a small and basic example of generating random images through PHP!
[PHP]//This line prevents a regular pattern of numbers to be generated.
Srand(microtime() * 1000000);
//This line creates a random integer between 1 and 3
$num = rand(1,3);
//Next we will use a switch statement to display the random image.
Switch($num)
{
case 1: $link=1; $img=images/img1.jpg; break;
case 2: $link=2; $img=images/img2.jpg; break;
case 3: $link=3; $img=images/img3.jpg; break;
}
//Now we will echo the dynamic content.
echo$link><img; [/PHP]
Random Image Generator In PHP
-
- Posts: 504
- Joined: Sat May 07, 2005 8:03 am
- Contact:
you can make it with javascript also
and by the way why do you need this?
do you want to use it for checking for humans?
i mean ask them to enter the code that is in the image?
if yes, then i should say that this not a very good idea
you better generate images with php and fill it with random text
and random numbers
and by the way why do you need this?
do you want to use it for checking for humans?
i mean ask them to enter the code that is in the image?
if yes, then i should say that this not a very good idea
you better generate images with php and fill it with random text
and random numbers
-
- Posts: 28
- Joined: Fri Apr 14, 2006 11:21 am