variable not in function
Posted: Thu Jul 04, 2002 2:38 pm
Hi folks,
Go easy on me here 'cause I think there is an easy answer to this but I can't figure it out.
I have a variable at the top of my page and a case statement then some functions down below. However, the variable at the top doesn't get passed down into the functions. I have to restate it in the function.
Pseudo-code:
that echo won't output anything unless I change the function to:
I haven't bothered to make sure I have every apostraphe, semicolon and comma in here, I just need to know why the variable needs redeclared or whatever you call it.
Thanks a bunch in advance.
Go easy on me here 'cause I think there is an easy answer to this but I can't figure it out.
I have a variable at the top of my page and a case statement then some functions down below. However, the variable at the top doesn't get passed down into the functions. I have to restate it in the function.
Pseudo-code:
Code: Select all
$pie = "apple";
switch "submit" {
case "submit pie":
MyPie($submit);
break;
default:
break;
}
function MyPie($submit) {
echo $pie;
}Code: Select all
function MyPie($submit) {
$pie = "apple";
ecoh $pie;
}Thanks a bunch in advance.