PHP 'Variable variables' dont seem to work

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP 'Variable variables' dont seem to work

Postby cretaceous » 03. March 2009 12:20

I've just moved over to Xampp and apart from Vista setup problems (scope for a sticky I think) it seems good

BUT parsing php "variable variables" does not work

so this script works fine on my other WAMP stack and works fine on Linux servers, but does not work on Xampp:
Code: Select all
$variables = array(
'itm_ord',
'itm_navttl'
);

ksort($variables);
ksort($_REQUEST);

foreach ($variables as $var) {
$$curvar=  mysql_escape_string(trim($_REQUEST[$var]));
}

// variable should now hold value of REQUEST object
echo $itm_ord;


any ideas why it is not working?
cretaceous
 
Posts: 2
Joined: 03. March 2009 12:11

Re: PHP 'Variable variables' dont seem to work

Postby Wiedmann » 03. March 2009 12:32

// variable should now hold value of REQUEST object

Why should this happens? You have only one variable variable, "$$curvar", but "$curvar" is nowhere defined.

(You should use error_reporting(E_ALL); to find such errors.)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP 'Variable variables' dont seem to work

Postby cretaceous » 03. March 2009 18:57

thankyou thankyou - you made me see the obvious mistake I'd missed !!
cretaceous
 
Posts: 2
Joined: 03. March 2009 12:11


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 54 guests