Write a program to print “Hello PHP” using variable
Description: Write a PHP program to print “Hello PHP” using a variable.
Rules and hints:
- You can not write the text directly in
echo. - Store the text in a variable first, and then print the variable.
PHP program to print Hello PHP using a variable
<?php
$message = "Hello PHP";
echo $message;
?>
Output:
Tutorials Class - Output Window
Hello PHP
How it works
$messageis a variable that stores the text.echo $message;prints the value of the variable.
Related: PHP Variables.
Learn more about the similar topics:
| Tutorials |
|---|
| PHP Variables |
| PHP Data Types |
| PHP Constants |
| PHP isset() Function |
| PHP empty() Function |
| PHP is_null() Function |
| Exercises & Assignments |
|---|
| Write a program to print “Hello PHP” using variable |
| Write a program to print a string using echo+variable. |
| Write a program to print two variables in single echo |