Ok, a little lesson on scope. What happens inside of a function stays inside of a function. Since you created the variable $bar inside the function the only place where $bar is valid is inside that funciton.
Now to fix your problem you can do either of these things:
function set_value_of_foo() {
$bar = "whatever";
session_register("bar");
return $bar; //do I need to do that? Yes leave this for this example
}
$bar = set_value_of_foo();
function print_foo($bar) { //here is where I run into trouble
print($bar);
}
print_foo($bar);
Or
function set_value_of_foo() {
$bar = "whatever";
session_register("bar");
// return $bar; //do I need to do that? No you don't need it for this example.
}
set_value_of_foo();
function print_foo($bar) { //here is where I run into trouble
print($bar);
}
print_foo($_SESSION['bar']);