You are currently viewing php linkedin assessment answers
php linkedin assessment answers_theanswershome

php linkedin assessment answers

1. What is the best way to explain what this script does?

1 if (!$_SESSION[ 'myusername'])
2 {
3 header ('location: /login.php');
4 exit;
5 }

  • This script times out the session for myusername.
  • This script validates the username and password.
  • This script is on a page that requires the user to be logged in. It checks to see if the user has a valid session.
  • Cookies are starting to be stored as a result of this script.

2. What is a key difference between GET and POST?

  • GET displays the submitted data as part of the URL. During POST, this information is not shown, as it’s encoded in the request body.
  • GET is more secure than POST and should be used for sensitive information.
  • GET is intended for changing the server state and it carries more data than POST.
  • GET is used with the HTTP protocol. POST is used with HTTPS.

3. Which code snippet uses the correct syntax for creating an instance of the Pet class?

  • all of these answers
  • $horse = (new Pet) ;
  • $dog = new Pet;
  • $cat = new Pet();

4. What are some of the main types of errors in PHP?

  • semantic, logical, syntax
  • runtime, logical, compile
  • notices, warnings, fatal
  • warnings, syntax, compile

5. Which is the most complete list of data types that PHP supports?

  • string, integer, float, boolean, array, object, NULL, resource
  • string, integer, float, array, object, NULL, resource
  • string, integer, boolean, array, object, NULL, resource
  • string, integer, float, boolean, array, object, NULL

6. Variable names are case- ______. Function names are case- ______. Class names are case- _______.

  • sensitive; insensitive; insensitive
  • insensitive; sensitive; insensitive
  • insensitive; insensitive; sensitive
  • sensitive; sensitive; insensitive

7. Which code would you use to print all the elements in an array called $cupcakes?

  • all of these answers
  • foreach ($cupcakes as &$cupcake) echo $cupcake;
  • var_dump ($cupcakes);
  • print_r($cupcakes);

8. What are getters and setters?

  • Getters and setters encapsulate the fields of a class by making them accessible only through its private methods, and keep the values themselves public.
  • Getters and setters are utility functions within PHP that allow loading from, and saving to, a database.
  • Getters and setters ensure that if a data member is declared private, then it can be accessed only within the same function, not by an outside class.
  • Getters and setters are methods used to declare or obtain the values of variables, usually private ones.

9. Imagine a web application, built following an MVC architecture, that contains a quiz and a button to score it. When the user presses the Score button, which component should handle the request?

  • model
  • router
  • controller
  • view

10. The PHP function array reduce () takes a callback function that accepts a value carried over each iteration and the current item in the array, and reduces an array to a single value. Which code sample will sum and output the values in the provided array?

11. 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'd use _____. If you want to check if an array contains a particular string _____ value at a particular index, you'd use _______.

  • compare; triples; doubles
  • compare; doubles; triples
  • assign; doubles; triples
  • assign; triples; doubles

12. What does this code print?

  • Handy Smurf
  • Smurfette
  • nothing
  • Papa Smurf

13. PHP supports multiple types of loops. If you wanted to loop through a block of code if and as long a specified condition is true, which type of loop would you use?

  • for
  • do-while
  • foreach
  • while

14. How might you troubleshoot a "call to undefined function" error?

  • Make sure you have imported the file containing the function.
  • all of these answers
  • Make sure you have spelled the function name correctly.
  • Make sure the function declaration is at an earlier point in the code than the function call.

15. Which code will return the IP address of the client?

  • $_SESSION[“REMOTE_ADDR”];
  • $HTTP_SERVER_VARS ( “REMOTE IP” )
  • getenv ( “REMOTE_ADDR”)
  • $_SERVER[ “HTTP_X_FORWARDED FOR”]

Leave a Reply