PHP Test
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 14% Most missed: “Which code will return the IP address of the client?”

PHP MCQs For LinkedIn Skill Assessments.

PHP Test
Time left 00:00
25 Questions

1. When it comes to the value of a variable, what is the difference between NULL and empty?
2. If you want to pass a formfield to another page when a button is clicked, you should use the ' . If you want to store information across multiple pages, you should use the ' ?
3. What is the output of this script?
php
$my_text = 'The quick grey [squirrel].';
preg_match('#\[(.*?)\]#', $my_text, $match);
print $match[1].'\n';
4. Assuming the 'Horse' class exists, which is a valid example of inheritance in PHP?
5. What type of computer language is PHP?
6. Which function can you use in error handling to stop the execution of a script and is equivalent to exit()?
7. Both triple === and double == can be used to ' variables in php. If you want to hear that string '33' and the number 33 are equal, you would use ' . If you want to check if an array contains a particular string value at a particular index, you would use \_
8. The ' operator is useful for sorting operations. It compares two values and returns an integer less than, equal to, or greater than 0 depending on whether the value on the ' is less than, equal to, or greater than the other.
9. What does this script do?
php
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
if ($email === false) {
$emailErr = 'Please re-enter valid email';
}
10. Which code would you use to print all the elements in an array called '$cupcakes'?
11. What is the cause of 'Cannot modify header information - headers already sent'?
12. Which script might be used to continue a user's search for music, across different webpages?
13. Which are valid PHP error handling keywords?
14. Which is not true of the 'toString()' in PHP?
15. What displays in a browser when the following code is written? ''
16. A PDO object called '$db' has been set up to use for database operations, including user authentication. All user-related properties are set. The script line 'public function __construct(&$db)' shows a constructor that initializes all user-related properties to \_ if no user has logged in. These parameters will be properly set by the login functions when a user logs in.
17. How might you troubleshoot a 'call to undefined function' error?
18. Why is it not recommended to make all of a class's variables public?
19. Which line could you NOT use to comment out 'Space: the final frontier'?
20. In the following script, which line(s) will cause an error(s)?

1 2 $count = 0;
3 $_xval = 5;
4 $_yval = 1.0;
5 $some_string = 'Hello there!';
6 $some_string = 'How are you?';
7 $will i work = 6;
8 $3blindmice = 3;
9 ?>
21. The following XML document is in books.xml. Which code will output 'Historical'?
xml


A Tale of Two Cities
Charles Dickens

Classics
Historical



Then There Were None
Agatha Christies

Mystery



22. In PHP 7, What is the correct way to import multiple classes from namespace in a single declaration ?!
23. What is the significance of the three dots in this function signature?
php
function process(...$vals) {
// do some processing
}
24. What are getters and setters?
25. A PHP 'variable variable' takes the value of a variable and treats that as the name of a variable. For example, if '$var' is a variable then '$$var' is a variable variable whose name is the value of '$var'. Which script produces the output below, using variable variables?
php
Cat
Dog
Dog