View Single Post
  #1 (permalink)  
Old 10-30-2007, 07:07 AM
ackerley1 ackerley1 is offline
WebProWorld Pro
 
Join Date: Jul 2003
Location: Canada
Posts: 272
ackerley1 RepRank 0
Default Using Variables outside a function

I am trying to create function that will assign several variables during it's process, but I cannot seem to get those variables to display outside of the function.

function example ($input_var) {
if ($input_var == option1) {
$new_var = new_desired_output1;
}
else {
$new_var = new_desired_output2;
}
}


Then I define $input_var and have a call to the function in the page:
$input_var = some_var;
example ($input_var);

Then later in the page:
echo $new_var;

But the last bit does not work?

Is there a trick to get the new variable out of the function? I can get it to work inside the function, but not outside??

Thanks
__________________
Rob
Reply With Quote