0
0
PHPprogramming~20 mins

First PHP program (Hello World) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PHP Hello World Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this PHP code?
Look at this PHP code. What will it print when run?
PHP
<?php
 echo "Hello World!";
?>
Ahello world!
BHello World!
CHelloWorld!
DSyntax Error
Attempts:
2 left
💡 Hint
Remember PHP is case sensitive in strings and echo prints exactly what is inside quotes.
Predict Output
intermediate
2:00remaining
What error does this PHP code produce?
This PHP code is missing something. What error will it cause?
PHP
<?php
 echo "Hello World!"
?>
AParse error: syntax error, unexpected end of file
BHello World!
CFatal error: Uncaught Error
DNo output
Attempts:
2 left
💡 Hint
Check if all statements end properly in PHP.
🧠 Conceptual
advanced
2:00remaining
Which PHP tag is correct to start PHP code?
You want to write PHP code inside an HTML file. Which tag correctly starts PHP code?
A<?php
B<php>
C<?phpcode>
D<script php>
Attempts:
2 left
💡 Hint
PHP code always starts with a special opening tag.
Predict Output
advanced
2:00remaining
What is the output of this PHP code?
What will this PHP code print?
PHP
<?php
 echo "Hello" . " " . "World!";
?>
AHello . World!
BHelloWorld!
CHello World!
DHello . World!
Attempts:
2 left
💡 Hint
The dot (.) operator joins strings in PHP.
Predict Output
expert
2:00remaining
What is the output of this PHP code with variables?
Look at this PHP code. What will it print?
PHP
<?php
 $greeting = "Hello";
 $target = "World!";
 echo "$greeting $target";
?>
AHello $target
B$greeting $target
CHello$target
DHello World!
Attempts:
2 left
💡 Hint
Variables inside double quotes are replaced by their values in PHP.