I'm trying to figure out how I can use a variable that has been set outside a function, inside a function. Is there any way of doing this? I've tried to set the variable to "global" but it doesn't seems to work out as expected.

A simple example of my code

$var = '1';

function() {
    $var + 1;
    return $var;
}

I want this to return the value of 2.

Edit
Report