Skip to content
FullStackDost Logo
  • All Courses
  • Blogs
  • Login
  • Register
  • All Courses
  • Blogs
  • Login
  • Register
  • Home
  • All Courses
  • Full Stack Development
  • PHP Tutorial

PHP Tutorial

Curriculum

  • 6 Sections
  • 29 Lessons
  • 3 Weeks
Expand all sectionsCollapse all sections
  • PHP Tutorials
    PHP (Hypertext Preprocessor) is a widely-used open-source scripting language primarily designed for web development.
    3
    • 1.1
      PHP Introduction
      20 Minutes
    • 1.2
      PHP Installation
      15 Minutes
    • 1.5
      PHP Syntax
      35 Minutes
  • PHP Basics
    PHP Basics Unleashed: Dive into the Fundamentals of Web Development!
    10
    • 2.0
      PHP Variables
      30 Minutes
    • 2.1
      PHP Arrays
      35 Minutes
    • 2.2
      PHP Conditions
      40 Minutes
    • 2.3
      PHP Loops
      45 Minutes
    • 2.4
      PHP Functions
      40 Minutes
    • 2.5
      PHP Array Functions
      20 Minutes
    • 2.6
      PHP String Functions
      35 Minutes
    • 2.7
      PHP Superglobals
      25 Minutes
    • 2.8
      PHP GET & POST
      30 Minutes
    • 2.9
      PHP Cookies
      45 Minutes
  • PHP Forms
    Streamline Your Web Forms: Master PHP Form Handling for Seamless User Interactions!
    3
    • 3.0
      PHP Forms
    • 3.1
      PHP Form Validation
      35 Minutes
    • 3.2
      PHP Form essentials
      20 Minutes
  • PHP Advance Topics
    Advanced topics in PHP cover a range of more complex concepts and techniques that are useful for experienced developers looking to build sophisticated web applications.
    8
    • 4.0
      PHP Date and Time
      35 Minutes
    • 4.1
      PHP File Handling
      45 Minutes
    • 4.2
      PHP Sessions
      35 Minutes
    • 4.3
      PHP Filters
      35 Minutes
    • 4.4
      PHP OOPS
      60 Minutes
    • 4.5
      PHP Traits
      45 Minutes
    • 4.6
      PHP Interface
      40 Minutes
    • 4.7
      PHP File upload
      45 Minutes
  • PHP Security
    Fortify Your PHP Skills: Learn Essential Security Practices to Safeguard Your Web Applications!
    1
    • 5.0
      Securing PHP application
  • Discussions on PHP
    Unlock the Power of PHP: Balancing Conciseness and Clarity for Readable Code Mastery
    4
    • 6.0
      Advantages of PHP
    • 6.1
      Disadvantages of PHP
    • 6.2
      Performance of PHP
    • 6.3
      Comparison with Node/JavaScript

PHP Superglobals

Superglobals in PHP are predefined variables that are always accessible from any scope of a script. They provide valuable information about the server, client, and environment. Here are some of the most commonly used PHP superglobals:

1. $_GET:

  • Contains variables passed to the current script via the URL parameters (query string).
  • Data is accessible using keys in the associative array format.

// URL: http://example.com/?name=John&age=30
echo $_GET['name']; // Output: John
echo $_GET['age']; // Output: 30

2. $_POST:

  • Contains variables passed to the current script via HTTP POST method.
  • Data is accessible using keys in the associative array format.

echo $_POST['username'];
echo $_POST['password'];

3. $_REQUEST:

  • Contains data from both $_GET and $_POST as well as cookies.
  • Data is accessible using keys in the associative array format.

echo $_REQUEST['name'];

4. $_SESSION:

  • Contains session variables created and maintained on the server.
  • Used to store user-specific information across multiple pages.

session_start();
$_SESSION['username'] = 'John';

5. $_COOKIE:

  • Contains cookies sent by the client to the server.
  • Data is accessible using keys in the associative array format.

echo $_COOKIE['username'];

6. $_FILES:

  • Contains information about uploaded files via HTTP POST method.
  • Provides details such as file name, type, size, etc.

echo $_FILES['file']['name'];
echo $_FILES['file']['type'];

7. $_SERVER:

  • Contains information about the server environment and the current script.
  • Provides details such as server name, script name, request method, etc.

echo $_SERVER['SERVER_NAME'];
echo $_SERVER['REQUEST_METHOD'];

8. $_ENV:

  • Contains variables from the environment.
  • Provides details such as the current user, home directory, etc.

echo $_ENV['USER'];
echo $_ENV['HOME'];

Superglobals are extremely useful in PHP programming as they provide a convenient way to access and manipulate various aspects of the server, client, and environment. However, it’s essential to handle them with care, especially when dealing with user input, to prevent security vulnerabilities such as SQL injection and cross-site scripting (XSS) attacks.

PHP String Functions
Prev
PHP GET & POST
Next

Copyright © 2025 FullStackDost. All Rights Reserved.

Theme by ILOVEWP