PHP Variables
PHPVariables in PHP start with a $ sign. No need to declare the type — PHP figures it out automatically.
Rules
- Must start with
$followed by a letter or underscore - Case-sensitive:
$nameand$Nameare different - No need to declare type (string, int, etc.)
Example — PHP
<?php
$name = "Rahul";
$age = 20;
$height = 5.8;
$isStudent = true;
echo "Name: " . $name . "<br>";
echo "Age: " . $age . "<br>";
echo "Height: " . $height . " feet<br>";
echo "Student: " . ($isStudent ? "Yes" : "No");
?>
Result
Name: Rahul
Age: 20
Height: 5.8 feet
Student: Yes
Age: 20
Height: 5.8 feet
Student: Yes