Jump to content

Archived

This topic is now archived and is closed to further replies.

otha

variable scope

Recommended Posts

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?

Share this post


Link to post
Share on other sites
You need to use the $_POST global. eg;

[code=php:0]
$_POST['offsetf']
[/code]

Share this post


Link to post
Share on other sites
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, $GLOBALS

All have global scope!

me!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.