[eluser]halwaraj[/eluser]
I have two functions. I need to access values from one in other how do i do it?
Here is what i want to do.
Code:
function a(){
$a=1;
$b=2;
}
now, I need to use the variables from the above function in otr func.
Code:
function b(){
echo $c=$a+$b;
}
I tried global but no luck. Here is what I tried:
Code:
<?php
$a,$b;
class R{
function a(){
global $a,$b;
$a=1;
$b=2;
}
function b(){
global $a,$b;
$c=$a+$b;
echo $c;
}
}
?>
As soon as I come to function b, $a and $b are empty.
How do I access those values?