0
0
PHPprogramming~15 mins

Why output functions matter in PHP - See It in Action

Choose your learning style9 modes available
Why output functions matter
📖 Scenario: Imagine you are creating a simple PHP script to show a message to your website visitors. To see the message, you need to use output functions that send text to the browser.
🎯 Goal: You will build a PHP script that stores a message and then uses an output function to display it on the screen.
📋 What You'll Learn
Create a variable to hold a message string
Create a variable to hold a greeting prefix
Combine the greeting and message using concatenation
Use an output function to display the combined message
💡 Why This Matters
🌍 Real World
Websites use PHP output functions to show text, images, and other content to visitors.
💼 Career
Knowing how to display information is a basic skill for web developers working with PHP.
Progress0 / 4 steps
1
Create a message variable
Create a variable called $message and set it to the string 'Welcome to our website!'.
PHP
Need a hint?

Use the = sign to assign the string to the variable.

2
Create a greeting variable
Create a variable called $greeting and set it to the string 'Hello! ' (note the space after the exclamation mark).
PHP
Need a hint?

Remember to include the space after the exclamation mark inside the quotes.

3
Combine greeting and message
Create a variable called $fullMessage and set it to the combination of $greeting and $message using the concatenation operator ..
PHP
Need a hint?

Use the dot . to join two strings in PHP.

4
Display the combined message
Use the echo statement to output the variable $fullMessage so it shows on the screen.
PHP
Need a hint?

The echo statement sends text to the browser so users can see it.