PHP Basics - syntax, variables, data types, operators, control structures, mixing PHP with HTML - Question Bank
1. What is the purpose of the `empty()` function in PHP?
2. PHP variables are case-sensitive. Which of the following are different variables?
3. Which PHP construct is used to define a constant?
4. What is the result of the expression `'5 apples' + 2` in PHP?
5. What is the result of the expression `'5' + 2` in PHP?
6. What is the result of the expression `5 + '2'` in PHP?
7. Which operator is used for string concatenation in PHP?
8. What is the syntax for a multi-line comment in PHP?
9. What is the syntax for a single-line comment in PHP?
10. How do you output the value of a PHP variable `$count` within an HTML paragraph tag?
11. Which PHP superglobal array contains all the variables from GET, POST and COOKIE?
12. If you have an HTML form with a GET method, how can you access the submitted data in PHP?
13. If you have an HTML form with a POST method, how can you access the submitted data in PHP?
14. Which HTML tag is commonly used to embed PHP code within an HTML document?
15. What is the PHP function used to output a string and can accept multiple arguments?
16. Consider the following PHP code snippet: `$name = 'World'; echo 'Hello, ' . $name . '!';` What will be the output?
17. How can you output a variable's value within an HTML context using PHP?
18. What is the purpose of mixing PHP with HTML?
19. In a switch statement, what keyword is used to end a case and move to the next?
20. Which control structure is used to execute different blocks of code based on the value of a variable?
21. Which loop structure is used to iterate over arrays and objects?
22. Which loop structure executes the code block once, and then continues as long as a condition is true?
23. Which loop structure continues as long as a condition is true?
24. Which loop structure is used when you know how many times you want to loop?
25. Which control structure allows you to execute a block of code multiple times?
26. Which control structure is used to execute a block of code if a condition is true, and another block if the condition is false?
27. Which control structure is used to execute a block of code only if a specified condition is true?
28. What is the PHP operator for logical NOT?
29. What is the PHP operator for logical OR?
30. What is the PHP operator for logical AND?
31. What is the PHP operator for comparison (not equal to)?
32. What is the PHP operator for comparison (identical to - value and type)?
33. What is the PHP operator for comparison (equal to)?
34. What is the PHP operator for assignment?
35. What is the PHP operator for modulo (remainder of division)?
36. What is the PHP operator for division?
37. What is the PHP operator for multiplication?
38. What is the PHP operator for subtraction?
39. What is the PHP operator for addition?
40. Which PHP data type is used to store arrays?
41. Which PHP data type represents an object that has no value?
42. Which PHP data type can store one of two values: TRUE or FALSE?
43. Which PHP data type is used to store text?
44. Which PHP data type is used to store decimal numbers?
45. Which PHP data type is used to store whole numbers?
46. What is the default value for a variable that has been declared but not assigned a value in PHP?
47. How do you declare a variable in PHP?
48. Which symbol is used to end a PHP code block?
49. Which symbol is used to start a PHP code block?
50. What is the standard file extension for PHP files?