Concept Flow - Variable declaration with dollar sign
Start
Write $variableName
Assign value
Use variable
End
In PHP, variables always start with a dollar sign ($), then a name, then you assign a value. You can then use the variable.
<?php $age = 25; echo $age; ?>
| Step | Code Line | Action | Variable State | Output |
|---|---|---|---|---|
| 1 | $age = 25; | Declare $age and assign 25 | $age = 25 | |
| 2 | echo $age; | Print value of $age | $age = 25 | 25 |
| 3 | End | Program ends | $age = 25 |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| $age | undefined | 25 | 25 | 25 |
PHP variables always start with a $ sign. Syntax: $variableName = value; Use $variableName to access the value. Without $, PHP won't recognize it as a variable. Variables hold data you can reuse. Example: $age = 25; echo $age;