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 Variables

Variables in PHP are used to store data values. In PHP, a variable starts with the dollar sign ($) followed by the name of the variable. Here’s an overview of PHP variables:

Rules for PHP Variables:

  1. Variable names must start with a letter or underscore (_) character.
  2. Variable names cannot start with a number.
  3. Variable names can only contain alphanumeric characters and underscores.
  4. Variable names are case-sensitive ($variable is different from $Variable).
  5. PHP does not require variable declaration explicitly before using them.

Variable Declaration and Assignment:

  • $name = "John"; // Assigning a string value to a variable
    $age = 30; // Assigning an integer value to a variable
    $height = 5.9; // Assigning a floating-point value to a variable
    $isStudent = true; // Assigning a boolean value to a variable

Variable Output:

  • echo $name; // Output: John
    echo $age; // Output: 30
    echo $height; // Output: 5.9
    echo $isStudent; // Output: 1 (true value in PHP is displayed as 1)

Variable Scope:

  • Local Scope: Variables declared inside a function have local scope and can only be accessed within that function.
  • Global Scope: Variables declared outside of any function have global scope and can be accessed from anywhere in the script.

Example of Local and Global Scope:

  • $globalVariable = "I am a global variable";
    function testScope() {
     $localVariable = "I am a local variable";
     echo $globalVariable; // Error: $globalVariable is not accessible inside the function
     echo $localVariable; // Output: I am a local variable
    }
    testScope();
    echo $globalVariable; // Output: I am a global variable
PHP Syntax
Prev
PHP Arrays
Next

Copyright © 2025 FullStackDost. All Rights Reserved.

Theme by ILOVEWP