Header Ads Widget

Responsive Advertisement

Learn about PHP Superglobals with easy-to-understand examples and a fun quiz. Perfect for beginners!

illustration by Kartick Dutta
illustration by Kartick Dutta
illustration By © Kartick Dutta
Learn PHP Superglobals

PHP Superglobals

Superglobals are special variables in PHP:

  • They are always available in all parts of your code.
  • You don't need to declare them; they are already there.

How to Use PHP Superglobals?

  • Use them to get data: Like from forms or URLs.
  • Example: $_GET['name'] can get a name from a URL.

When to Use PHP Superglobals?

  • When you need to collect data: Like from a form on a website.
  • When you want to send data: Between pages or from a URL.

Key Superglobals:

  • $_GET: To get data from the URL.
  • $_POST: To get data from a form.
  • $_SERVER: To get information about the server.
  • $_SESSION: To store data across different pages.
  • $_COOKIE: To store data in the user's browser.

Quiz: Test Your Knowledge!






  • Correct! The $_GET superglobal is used to collect data sent in the URL.

    Explanation: The $_GET superglobal is used to collect data after submitting an HTML form with method="get". It can also collect data sent in the URL.





  • Correct! The $_SESSION superglobal is used to store data across different pages.

    Explanation: The $_SESSION superglobal is used to store data across different pages. This data is stored on the server and is unique to each user.





  • Correct! The $_SERVER superglobal contains information about headers, paths, and script locations.

    Explanation: The $_SERVER superglobal contains information about headers, paths, and script locations. It provides details such as server software and request headers.





  • Correct! The $_COOKIE superglobal is used to store data in the user's browser.

    Explanation: The $_COOKIE superglobal is used to store data in the user's browser. This data persists between page requests and sessions.





  • Correct! The $_POST superglobal is used to collect form data after submitting an HTML form with method="post".

    Explanation: The $_POST superglobal is used to collect form data after submitting an HTML form with method="post". It is often used for form submissions requiring data to be sent securely.
Score: 0/5
Join Our Premium Coding Classes

Learn Coding with Our Expert Teachers

Join Our Premium Classes Today

Post a Comment

0 Comments