PHP Tutorial - Variables & Data Types

Unlock Premium Features: AI explanations (Hinglish), Indian voice & Videos
Sign Up Free

๐Ÿ“ฆ Variables Aur Data Types

๐ŸŒŸ Container Analogy:

๐Ÿ“ฆ Variable = Dabba (storage)
๐Ÿท๏ธ $ sign = PHP ka symbol
๐Ÿ“ Value = Dabba mein rakha data

Example: $age = 25;

๐Ÿ“ Variable Rules

  • Start with $ (dollar sign)
  • Letter or underscore after $
  • Case-sensitive ($age โ‰  $Age)
  • No spaces allowed

๐Ÿ“Š Data Types

TypeExampleUse
String"Hello", 'World'Text
Integer25, -10Whole numbers
Float3.14, 25.5Decimals
Booleantrue, falseYes/No
Array["a", "b"]Lists
NULLnullEmpty

๐ŸŽฏ Variable Scope

3 Types
// Local - function ke andar
function test() {
    $local = "inside";
}

// Global - bahar
$global = "outside";

// Static - value retain
static $count = 0;

๐Ÿค– AI Tutor Unlock Karo!

Apni language mein coding seekho - Hindi, Marathi, Gujarati aur 10+ Indian languages mein!

  • Hinglish mein explanations
  • Real-life examples
  • Beginner-friendly
Free Signup Karo

Example

<?php
$name = "Rohan";
$age = 25;
$height = 5.8;
?>