🟢 Foundation  ·  Lesson 04

Variables in PHP

Variables in PHP

PHP Variables

A variable in PHP starts with a $ sign. You do not declare a type — PHP figures it out automatically (loosely typed).

Examples

<?php
  $name = "Aman";
  $age = 18;
  $price = 99.5;
  $isStudent = true;
  echo "$name is $age years old";
?>
Aman is 18 years old

Variable Rules

  • Must start with $ followed by a letter or underscore.
  • Case-sensitive: $name and $Name are different.
  • No spaces or special characters in the name.

Summary

  • PHP variables start with $; no type declaration needed.
  • Case-sensitive; start with a letter or underscore.

PHP Variables

PHP में variable $ चिह्न से शुरू होता है। आप type declare नहीं करते — PHP खुद पता लगा लेती है (loosely typed)।

Examples

<?php
  $name = "Aman";
  $age = 18;
  $price = 99.5;
  $isStudent = true;
  echo "$name is $age years old";
?>
Aman is 18 years old

Variable नियम

  • $ के बाद letter या underscore से शुरू हो।
  • Case-sensitive: $name और $Name अलग हैं।
  • नाम में spaces या special characters नहीं।

सारांश

  • PHP variables $ से शुरू; type declare करने की ज़रूरत नहीं।
  • Case-sensitive; letter या underscore से शुरू।
← Back to PHP Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।