• I am trying to save a variable and its value (e.g. $id = 1) across functions. The variable gets its value in Function1, and I would like to use the value in Function 2.

    How can I do this? Thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • function one() {
    global $id;
    $id = 1;
    }
    function two() {
    global $id;
    echo $id;
    }
    Thread Starter apascal

    (@apascal)

    I didn’t know you were supposed to declare a variable globally in the first function!

    Thanks a lot 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to “save” variable values across functions?’ is closed to new replies.