0
0
PHPprogramming~10 mins

Print statement in PHP - Mini Project: Build & Apply

Choose your learning style9 modes available
Print statement
📖 Scenario: You are creating a simple PHP script to display a welcome message on a webpage.
🎯 Goal: Learn how to use the print statement in PHP to show text output.
📋 What You'll Learn
Create a string variable with a welcome message
Use a print statement to display the message
💡 Why This Matters
🌍 Real World
Displaying messages and information on web pages using PHP is a common task in web development.
💼 Career
Knowing how to output text in PHP is essential for backend web developers to communicate with users and debug code.
Progress0 / 4 steps
1
Create a message variable
Create a string variable called message and set it to "Hello, welcome to PHP!".
PHP
Need a hint?

Use $message = "Hello, welcome to PHP!"; to create the variable.

2
Use print statement
Use the print statement to display the value of the message variable.
PHP
Need a hint?

Use print($message); to show the message.

3
Add a newline after the message
Modify the print statement to add a newline character \n after the message.
PHP
Need a hint?

Use string concatenation with . "\n" inside the print statement.

4
Print a second message
Create a new string variable called secondMessage with the value "Have a great day!" and use print to display it on the next line.
PHP
Need a hint?

Create $secondMessage and print it with a newline like the first message.