Welcome Guest, Not a member yet? Register   Sign In
Hello
#1

[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?


Messages In This Thread
Hello - by El Forum - 03-26-2009, 12:53 PM
Hello - by El Forum - 03-26-2009, 01:05 PM
Hello - by El Forum - 03-26-2009, 01:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB