Jump to content


Photo

variable scope


  • Please log in to reply
3 replies to this topic

#1 otha

otha
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 07 October 2006 - 12:23 AM

In the following function all of the variables except $topOpen are assigned values in a form (method=post),
the $offsetf is the name of a set of radio buttons, with top being one of the values.
$desireda is also given a value in the form on a html document.
<?
function desfaceError(){
$topOpen= ($offsetf== top);
if($topOpen)
{$desireda = $desireda;}
else
{$desireda = -$desireda;}
;
return $desireda; }
?>
is the scope of the variables my problem, or am I asking for the wrong return value? If the scope is the problem how do I declare the variables global? or is that the right way to be heading?

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 07 October 2006 - 12:29 AM

You need to use the $_POST global. eg;

$_POST['offsetf']


#3 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 07 October 2006 - 12:32 AM

Change local names to thier SUPER GLOBAL names!

Instead of....

$offsetf

Use...

$_POST['offsetf']


$_POST, $_GET, $_REQUEST, $_SERVER, $_FILES, $_SESSIONS, $_ENV, $_COOKIE, $GLOBALS

All have global scope!

me!

#4 otha

otha
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 07 October 2006 - 12:34 AM

Thanks folks, let me try that.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users