What i want to do:
Generate single random number which will be passed to functions inside the class.
In other words while calling $this->random both one() and two() should return same value
What is actually happening:
I have multiple random numbers because rand() is getting called multiple times
Important notes:
I want to avoid storing the number inside the session or SQL
How does my code look:
class Install
{
private $random= '';
public function __construct()
{
$this->random = rand(pow(10, 4-1), pow(10, 4)-1);
}
public function one()
{
echo $this->random; //example value = 3304
}
public function two()
{
echo $this-random; //example value = 2504
}
}