Concept Flow - First PHP program (Hello World)
Start PHP script
Execute echo statement
Output: Hello World
End script
The PHP script starts, runs the echo command to print 'Hello World', then ends.
<?php echo "Hello World";
| Step | Action | Evaluation | Output |
|---|---|---|---|
| 1 | Start PHP script | N/A | |
| 2 | Execute echo statement | echo "Hello World"; | Hello World |
| 3 | End script | N/A |
| Variable | Start | After Step 2 | Final |
|---|---|---|---|
| No variables | N/A | N/A | N/A |
<?php ... ?> tags mark PHP code start and end. echo prints text to the screen. This program outputs: Hello World No variables needed. Script runs top to bottom.
echo statement do in a PHP program?echoecho statement is used in PHP to display text or output on the screen.<?php and ?>, not echo. Variables are declared differently.<?php to tell the server to process PHP code.<php> and <?> are invalid tags. <script> is for JavaScript, not PHP.<?php echo "Hello World!"; ?>
echo command prints the string inside quotes to the screen exactly as it is.<?php echo "Hello World!" ?>
<?php echo "Hello World!"; echo "Welcome to PHP."; ?>correctly uses two echo statements with semicolons.
<?php echo "Hello World!\nWelcome to PHP."; ?>uses \n inside double quotes but PHP does not automatically print new lines in HTML output.
<?php print "Hello World!" print "Welcome to PHP."; ?>misses semicolon between print statements.
<?php echo "Hello World!" echo "Welcome to PHP."; ?>misses semicolon after first echo.
Pass the test and this pattern moves unknown