Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 15th, 2006, 10:09 AM   #1
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
$_POST to function

Can I pass everything in $_POST[] into a function? How would I go about that, just function($_POST) or something else? or should it just pass anyways because $_POST is a superglobal
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Mar 15th, 2006, 10:17 AM   #2
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 216
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
$_POST is an a global array. You can call any variable in POST by using $_POST['variable'] . You don't need to pass the actual array to a function because all functions should be able to access it.
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Old Mar 15th, 2006, 11:42 AM   #3
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
that's what I wasn't sure of, thank you.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Mar 15th, 2006, 11:47 AM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
I'm not sure you know this already, but you can also access global variables from a function without passing them as an argument:
$someGlobalVariable = "A value for a random, global variable";

function aRatherUselessFunction() {
  global $someGlobalVariable;

  echo $someGlobalVariable;
}
Polyphemus_ is offline   Reply With Quote
Old Mar 15th, 2006, 12:12 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
If the function is quite general, and can accept any array, passing $_POST to it should be fine. If it's been created specifically to deal with the $_POST array, as others have said, you can access it from directly within the function.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 20th, 2006, 3:58 PM   #6
cool & fit
Newbie
 
Join Date: Mar 2006
Posts: 1
Rep Power: 0 cool & fit is on a distinguished road
need help with content management system
cool & fit is offline   Reply With Quote
Old Mar 20th, 2006, 4:33 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Good ta know. Have fun finding it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 20th, 2006, 4:41 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
@ cool and fit: what's fit, your body? Your approach isn't, it sucks. Read the forum's rules/FAQ. Read the "How to Post a Question" thread at the top of the C forum. You're a new member -- check out the community before you decide it operates like your little brother's blog. The rules/FAQ also have a link to a "How to ask questions the smart way" document. That's a good one to read, too. Last, but not least, don't hijack another person's thread; particularly if your subject isn't even the same.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC