Re: Access $HTTP_POST_VARS from class member fucntion
| From: | Steve Edberg | Date: | Sun, 04 Nov 2001 23:49:44 +0000 |
| Subject: | Re: Access $HTTP_POST_VARS from class member fucntion | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73430@lists.php.net to get a copy of this message | ||
At 10:41 AM -0800 11/4/01, Daniel Harik wrote:
Hello I have a class called Member, it has member function called vallidateForm(), i try to pass it a $HTTP_POST_VARS array it looks like this: clas Member{ var $HTTP_POST_VARS; function vallidateForm ($HTTP_POST_VARS){Syntax here is wrong; you don't need to declare function arguments using var; only class variables need that. I'm uncertain what will happen if you do this. I would expect that - if PHP's error reporting were turned up to the maximum - it might give you a warning message. So do either: (1) Drop the 'var $HTTP_POST_VARS line; OR do (2) clas Member{ var $HTTP_POST_VARS; function vallidateForm (){echo $HTTP_POST_VARS['frmUsername'];} }
echo $this->HTTP_POST_VARS['frmUsername'];} } Although option (2) would require rewriting the code below. Also I assume that the 'clas Member{' line is just a typo, and your actual code says 'class Member{'...
$user = new Member; if($action=="register"){ global $HTTP_POST_VARS; $user->vallidateForm($HTTP_POST_VARS); }else{ $user->displayForm(); } ?> But i can't acces $HTTP_POST_VARS['frmUsername'] within the functionIf you are using an old (any PHP3.x, and I think some early betas of PHP4) version of PHP, you need to turn 'track_vars' on to enable $HTTP_POST_VARS and other $HTTP_xxx_VARS arrays. If that's the case - and you can't upgrade immediately - you need to turn track_vars on in httpd.conf, php.ini, or .htaccess (whatever's appropriate in your setup). Hope that helps - - steve edberg -- +--------------- my people are the people of the dessert, ---------------+ | Steve Edberg sbedberg@ucdavis.edu | | University of California, Davis (530)754-9127 | | Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ | +---------------- said t e lawrence, picking up his fork ----------------+