PHP Basics
Print a value from a PHP script.
PHP
<?php
$name = "Ada";
echo "Hello, $name\n";Output
Hello, Ada
Explanation
PHP variables begin with $. The echo statement writes to output; the newline character starts a new line in a terminal.
Explore the dry run
Guided walkthroughReady
1
<?php2
$name = "Ada";3
echo "Hello, $name\n";Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Assign Ada to the PHP variable. | $name = "Ada" | — | |
| Interpolate the variable and echo the result. | $name = "Ada" | Hello, Ada |