So I came across this piece of code to-day. I'm reasonably familiar with variable variables but I still don't really get this.
It's used to enumerate the value element of a submitted form's name-value pair. So that if your name-value pair was hidden=submit. Then you'd end up with a variable $submit, which could be used to guide your script eg.
... anyway this is the code
this is my a var_dump of $_POST and the results from test_var($$var)
????
It's used to enumerate the value element of a submitted form's name-value pair. So that if your name-value pair was hidden=submit. Then you'd end up with a variable $submit, which could be used to guide your script eg.
Code:
if ($submit){ // then other code here}
Code:
$params = array('submit' => 'hidden', 'style' => 'style' );
while( list($var, $param) = @each($params) )
{
if ( !empty($HTTP_POST_VARS[$param]) || !empty($HTTP_GET_VARS[$param]) )
{
$$var = ( !empty($HTTP_POST_VARS[$param]) ) ? htmlspecialchars($HTTP_POST_VARS[$param]) : htmlspecialchars($HTTP_GET_VARS[$param]);
// MY test_var function here test_var($$var);
}
else
{
$$var = '';
}
}
Code:
array(2) { ["hidden"]=> string(6) "submit" ["style"]=> string(7) "Classic" }
the value of submit is submit
the value of Classic is default value for presentation