Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:55:09+00:00 2026-06-16T09:55:09+00:00

Do I have to check whether the $_SERVER variable has a key REQUEST_METHOD before

  • 0

Do I have to check whether the $_SERVER variable has a key REQUEST_METHOD before actually using $_SERVER['REQUEST_METHOD']?

That is, is it overly defensive to always check whether a key exists in array variable like $_SERVER?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:55:11+00:00Added an answer on June 16, 2026 at 9:55 am

    The PHP-manual says the following about the $_SERVER-variable:

    There is no guarantee that every web server will provide any of these;
    servers may omit some, or provide others not listed here. That said, a
    large number of these variables are accounted for in the » CGI/1.1
    specification, so you should be able to expect those.

    The CGI/1.1 specification has the following to say:

    The REQUEST_METHOD meta-variable MUST be set to the method which
    should be used by the script to process the request, as described in
    section 4.3.

    and

    The Request Method, as supplied in the REQUEST_METHOD meta-variable,
    identifies the processing method to be applied by the script in
    producing a response. The script author can choose to implement the
    methods most appropriate for the particular application. If the
    script receives a request with a method it does not support it SHOULD
    reject it with an error (see section 6.3.3).

    It probably isn’t necessary to check for its existense if you aren’t doing any CLI-development and the script will only be run from a server like Apache. You could probably do it, to be on the safe side, but it is of no necessity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: using SQL Server 2005. I have a query that has to check whether
I have a series of commands that check whether a url looks something like
I have a Password Reset Functionality ,I have to check whether Old and New
Suppose you have an NxN matrix and you have to check whether it's a
I have been trying to check whether an NSInteger is odd or even. I
How can I check whether all JavaScript functions have loaded properly on a page?
I have a web application inside where i need to check whether the user
In a table column I have check boxes which gives me indicator whether i
Is there a quick way to check whether a path I have is on
If I have two different arrays and all I can do is check whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.