otha Posted October 7, 2006 Share Posted October 7, 2006 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? Link to comment https://forums.phpfreaks.com/topic/23232-variable-scope/ Share on other sites More sharing options...
trq Posted October 7, 2006 Share Posted October 7, 2006 You need to use the $_POST global. eg;[code=php:0]$_POST['offsetf'][/code] Link to comment https://forums.phpfreaks.com/topic/23232-variable-scope/#findComment-105328 Share on other sites More sharing options...
printf Posted October 7, 2006 Share Posted October 7, 2006 Change local names to thier SUPER GLOBAL names!Instead of....[code]$offsetf[/code]Use...[code]$_POST['offsetf'][/code]$_POST, $_GET, $_REQUEST, $_SERVER, $_FILES, $_SESSIONS, $_ENV, $_COOKIE, $GLOBALSAll have global scope!me! Link to comment https://forums.phpfreaks.com/topic/23232-variable-scope/#findComment-105329 Share on other sites More sharing options...
otha Posted October 7, 2006 Author Share Posted October 7, 2006 Thanks folks, let me try that. Link to comment https://forums.phpfreaks.com/topic/23232-variable-scope/#findComment-105331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.