Q:

Naming variables in recursive functions

My recursive function receives the variable $a as an argument, memorizes it as $b, then passes it to itself.
Question:
If I recursively call a function, can the variable I pass to the recursive call (line 4 of the function) have the same name as the memorized variable (line 1 of the function)?
Example 1
$a = "bob";

function do_someting($b)
{
    echo $b;
    if ($b == 'bob') {
        do_something($b);
    }
}

do_something($a);

Or must I pass a variable with a different name (lines 4 and 5 of this function)?
Example 2
function do_someting($b)
{
    echo $b;
    if ($b == 'bob') {
        $c = $b;
        do_something($c);
    }
}

The function, as it is given here, will cause an infinite loop. This is not my real code, just an example to illustrate my question. Don't run it.

A:

Take a look at variable scopes : PHP manual
Inside a function you reuse the variable name inside the scope, scope being start-end of function. If you call function recursively then inner scopes do not effect outer scope.
Consider function:
function decrements($b) {
   print "pre call $b={$b}\n\r";
   if($b>0) decrements(--$b);
   print "post call $b={$b}\n\r";
}

decrements(4);

Output would be:
pre call 4=4
pre call 3=3
pre call 2=2
pre call 1=1
pre call 0=0
post call 0=0
post call 0=0
post call 1=1
post call 2=2
post call 3=3

And if you insert $b = 4
decrements($b) { //$b = 4
  decrements($b) { //$b = 3
    decrements($b) { //$b = 2
      decrements($b) { //$b = 1
        decrements($b) { //$b = 0
        } //$b = 0
      } //$b = 0
    } //$b = 1
  } //$b = 2
} //$b = 3

