0
0
PHPprogramming~20 mins

Print statement in PHP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PHP Print 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 print statement?
Look at the PHP code below. What will it print when run?
PHP
<?php
print "Hello, " . "world!";
?>
AHello,world!
BHello, world!
CHello world!
DHello world
Attempts:
2 left
💡 Hint
Remember that the dot (.) joins strings exactly as they are.
Predict Output
intermediate
2:00remaining
What does this print statement output?
What will this PHP code print?
PHP
<?php
print(5 + 3);
?>
A8
B5 + 3
C53
DError
Attempts:
2 left
💡 Hint
The plus sign adds numbers, not strings, when used with numbers.
Predict Output
advanced
2:00remaining
What is the output of this PHP print with variables?
What will this PHP code print?
PHP
<?php
$name = "Alice";
print "Hello, $name!";
?>
AHello, !
BHello, $name!
CHello, Alice!
DError
Attempts:
2 left
💡 Hint
Variables inside double quotes are replaced by their values.
Predict Output
advanced
2:00remaining
What error does this PHP print statement cause?
What error will this PHP code produce?
PHP
<?php
print 'Hello, $name!';
?>
AUndefined variable error
BPrints Hello, Alice!
CParse error
DPrints Hello, $name!
Attempts:
2 left
💡 Hint
Single quotes do not replace variables with their values.
Predict Output
expert
2:00remaining
What is the output of this complex PHP print statement?
What will this PHP code print?
PHP
<?php
print "Sum: " . (2 + 3) . ", Product: " . (2 * 3);
?>
ASum: 5, Product: 6
BSum: 56
CSum: 5, Product: 2
DError
Attempts:
2 left
💡 Hint
Remember operator precedence: concatenation (.) and multiplication (*) have different priorities.