0
0
PHPprogramming~15 mins

Variable naming rules in PHP - Mini Project: Build & Apply

Choose your learning style9 modes available
Variable naming rules
📖 Scenario: Imagine you are organizing your personal notes in a notebook. Each note has a clear title so you can find it easily later. In programming, variables are like these notes. They need clear names so the computer and you understand what they hold.
🎯 Goal: You will create variables with proper names following PHP rules. Then, you will print their values to see the result.
📋 What You'll Learn
Create variables with valid PHP names
Assign simple values to these variables
Print the variables to show their values
💡 Why This Matters
🌍 Real World
Variable naming is important in all programming tasks to keep code clear and understandable.
💼 Career
Good variable names help developers read and maintain code, which is essential in any programming job.
Progress0 / 4 steps
1
Create variables with valid names
Create three variables called $name, $age, and $is_student. Assign the values "Alice", 23, and true to them respectively.
PHP
Need a hint?

Remember, PHP variables start with a dollar sign $ followed by letters, numbers, or underscores. They cannot start with a number.

2
Add a variable for height
Create a variable called $height_cm and assign it the value 170.
PHP
Need a hint?

Use underscores to separate words in variable names for readability.

3
Use variables in a message
Create a variable called $message that combines $name and $age into the string: "Alice is 23 years old." Use double quotes and variable interpolation.
PHP
Need a hint?

Use double quotes to include variables directly inside strings in PHP.

4
Print the message
Use echo to print the variable $message.
PHP
Need a hint?

Use echo to show text or variable values on the screen in PHP.