SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old January 24th, 2003, 04:10 PM
Niall Niall is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 Niall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Passing variables into functions and classes

Hi all,

Just a quick question. How do you pass a variable from a form into a function or class ? That is with register globals off and using something like $_POST['myVariable']. I'm new to all this stuff so please kind.


Thanks in advance,

Niall

Reply With Quote
  #2  
Old January 27th, 2003, 04:08 PM
ramz ramz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Juiz de Fora - MG- Brazil
Posts: 93 ramz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to ramz Send a message via MSN to ramz
Yes... with globals set to off, use this:

For post form method: $_POST['var_name'];
For get form method: $_GET['var_name'];

Or you can use a PHP special function that creates the variables for you, use this:

@import_request_variables("GP");

The @ symbol is to omit errors...
The G and P means: GET and POST.
Using this will make any form variable avaible at your script, even if globals are set to off.
You can even use the letter C too, that is for Cookies.
And don't forget, that if you use this, the variable name at your script will be the same name as the form field name. In example: if a form field is named: "txtZip" then you'll have a variable in your script named: $txtZip
__________________
Regards,
Ramiro Varandas Jr.

Reply With Quote
  #3  
Old February 4th, 2003, 03:35 PM
Niall Niall is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 Niall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply Ramiro.
Sorry it took me so long to get back to you.

all the best,

Niall

Reply With Quote
  #4  
Old February 4th, 2003, 07:36 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Quote:
Originally posted by ramz
Or you can use a PHP special function that creates the variables for you, use this:

@import_request_variables("GP");


Doesn't that just defeat the purpose of globals being off? Correct me if I'm wrong...
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #5  
Old February 5th, 2003, 05:28 AM
Jeb. Jeb. is offline
"l33t? What's l33t?"
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 51 Jeb. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to Jeb.
Not really, no r_g being off is to reduce the risks of variable poisioning - import_request_variables simply takes the GPC superglobals and effectively performs extract() on them all. There's no risk of variable poisoning this way.

But I'd still say stick with $_*.
__________________
Jeb.

AIM: JebediahMc - PM Me - E-Mail Me


Reply With Quote
  #6  
Old February 9th, 2003, 11:11 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Okay.... I wasn't sure what the main difference was. But as you said, I too, would rather stick with the superglobals!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Passing variables into functions and classes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway