-2

I have one variable as

$pwd="abcd";

I want this variable's value should be changed dynamically , every time this page is loaded. How to do this.

Pradeep
  • 61
  • 1
  • 1
  • 6

3 Answers3

1

If you are looking for random string, have a look at mt_rand(). Likewise you have many other options in PHP Manual. It generates integer but you can use it to get a character.

Jigar
  • 3,256
  • 1
  • 30
  • 51
1

Use this code for random unique value for each time

$pwd = md5(time() . rand(1, 1000))
1

If you want a simple random string generator, you could use something like this:

echo substr(str_shuffle(implode(range('a','z'))), 0, 5); // 5 is the length

If you want to generate random numbers, then use PHP's built-in function mt_rand()

$five_digit_random_number = mt_rand(10000, 99999);
Amal Murali
  • 75,622
  • 18
  • 128
  • 150