PHP is a popular language. What is its main use?
Think about where PHP code runs: on the server or the browser?
PHP runs on the server to create web pages that can change based on user input or data.
Look at this PHP code and choose the output it produces.
<?php $number = 5; echo $number * 2; ?>
Multiplying 5 by 2 gives what number?
The variable $number holds 5, multiplying by 2 results in 10.
Find the error in this PHP snippet and identify the error message.
<?php echo 'Hello World\n'; ?>
Check if all quotes and tags are properly closed.
The string is missing a closing quote, causing a syntax error.
Choose the correct way to declare a variable holding the number 10 in PHP.
Remember PHP variables start with a special symbol.
PHP variables always start with a dollar sign ($).
Analyze the code and find the value stored in $result.
<?php function add($a, $b = 3) { return $a + $b; } $result = add(4); ?>
Check the default value of the second parameter.
The function adds $a and $b. $b defaults to 3 if not given, so 4 + 3 = 7.