PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 24th, 2011, 09:16 AM
Sluap's Avatar
Sluap Sluap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Location: Somewhere in England
Posts: 204 Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 12 h 19 m 49 sec
Reputation Power: 30
PHP5 - If($_SERVER['REQUEST_METHOD']=="GET") vs if (isset($_POST

Hi

i have recently taken over a project from another developer, and something he had done boggled me a bit as i have never used it before

basically he used if($_SERVER['REQUEST_METHOD']=="GET") and i always use if (isset($_POST

now the application its self was to be a facbook app and the if($_SERVER['REQUEST_METHOD']=="GET") did not work so me changing it to if (isset($_POST worked in the FB tab.

i suppose my question is why would you use 1 over the other

Cheers

Reply With Quote
  #2  
Old January 24th, 2011, 09:42 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,440 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 14 h 37 m
Reputation Power: 3896
PHP hasn't always had $_GET and $_POST

It used to be $_REQUEST

and there was a precedence order as to what you would get in $_REQUEST['foo'] if a varibale called foo was sent in both get and post parts of the request.

Given that get and post are semantically different, it makes sense to a developer to know which method was used to send the data to the script, so you would look for the request method to choose what you wanted to do with the data.

Basically, it's code from php versions < 4
Comments on this post
ManiacDan agrees: Only the last line really matters, but good post.
__________________
PHP OOPS! <?php Output::Render(DB::Execute(SQL::makeFrom($_GET),$_GET)->fetchArray(),Template::getInstance('default')); ?>

PDO vs mysql_* functions: Find a Migration Guide Here

[ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]

Reply With Quote
  #3  
Old January 26th, 2011, 08:25 AM
Sluap's Avatar
Sluap Sluap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Location: Somewhere in England
Posts: 204 Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level)Sluap User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 12 h 19 m 49 sec
Reputation Power: 30
Quote:
Originally Posted by Northie
PHP hasn't always had $_GET and $_POST

It used to be $_REQUEST

and there was a precedence order as to what you would get in $_REQUEST['foo'] if a varibale called foo was sent in both get and post parts of the request.

Given that get and post are semantically different, it makes sense to a developer to know which method was used to send the data to the script, so you would look for the request method to choose what you wanted to do with the data.

Basically, it's code from php versions < 4


thanks for the information on the above 2 helped alot

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - If($_SERVER['REQUEST_METHOD']=="GET") vs if (isset($_POST

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap