Upwork Test Answers: Get all the correct answers of most recent and possible Upwork Tests A to Z (Updated on Jan, 2016)
Cover Letter Templates: These cover letter samples are not only for Upwork job, but also you will have some idea about your real life job
 
Freelance Profile Overviews: Different Profile samples and overviews of experts, advanced and intermediate level freelancers
For Newbie of Upwork: Upwork Help - How to apply for a job in Upwork with 10 most important articles about Upwork

A to Z View - All Upwork Test Answers

Upwork PHP Test Answers - Part 2

1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection.
 Answers: • Use PDO prepared statements and parameterized queries: for example: $input= $_POST["user-input"] $stmt = $pdo->prepare('INSERT INTO table (column) VALUES (":input"); $stmt->execute(array(':input' => $input));

 2. Which of the following methods should be used for sending an email using the variables $to, $subject, and $body?
 Answers: • mail($to,$subject,$body)

 3. Which of the following is used to maintain the value of a variable over different pages?
 Answers: • session_register()

 4. Which of the following will check if a function exists?
 Answers: • function_exists()

 5. Which of the following is not a file-related function in PHP?
 Answers: • fappend

 6. Which of the following is true about the singleton design pattern?
 Answers: • A singleton pattern means that a class can have only one instance object.

 7. Which of the following characters are taken care of by htmlspecialchars?
 Answers: • All of these


 8. Which of the following will read an object into an array variable?
 Answers: • $array_variable = get_object_vars($object);

 9. Which of the following variable declarations within a class is invalid in PHP?
 Answers: • internal $term = 3;

 10. Which of the following is not a PHP magic constant?
 Answers: • __TIME__

 11. Which of the following will print out the PHP call stack?
 Answers: • $e = new Exception; var_dump($e->getTraceAsString());

 12. What will be the output of the following code?
 <?php
 var_dump (3*4);
 ?>
 Answers: • int(12)

 13. Which of the following is correct about Mysqli and PDO?
 Answers: • Mysqli can only be used to access MySQL database while PDO can be used to access any DBMS.

 14. What is the correct way to send a SMTP (Simple Mail Transfer Protocol) email using PHP?
 Answers: • mail($EmailAddress, "Subject", $MessageBody);

 15. Which of the following will start a session?
 Answers: • session_start();

 16. For the following code:
 <?php

 function Expenses()
 {
 function Salary()
 {
 }

 function Loan()
 {
 function Balance()
 {
 }
 }
 }

 ?>
 Which of the following sequence will run successfully?
 Answers: • Expenses();Salary();Loan();Balance();

 17. What enctype is required for file uploads to work?
 Answers: • multipart/form-data

 18. Which of the following is incorrect with respect to separating PHP code and HTML?
 Answers: • As PHP is a scripting language, HTML and PHP cannot be separated.

 19. Which one of the following is not an encryption method in PHP?
 Answers: • bcrypt()

 20. What function should you use to join array elements with a glue string?
 Answers: • implode

 21. Which function can be used to delete a file?
 Answers: • unlink()

 22. What is the string concatenation operator in PHP?
 Answers: • .

 23. Which of the following is useful for method overloading?
 Answers: • __call,__get,__set

 24. Which of the following will store order number (34) in an 'OrderCookie'?
 Answers: • setcookie("OrderCookie",34);

 25. What would occur if a fatal error was thrown in your PHP program?
 Answers: • The PHP program will stop executing at the point where the error occurred.

 26. What is the correct line to use within the php.ini file, to specify that 128MB would be the maximum amount of memory that a script may use?
 Answers: • memory_limit = 128M

 27. What is the best way to change the key without changing the value of a PHP array element?
 Answers: • $arr[$newkey] = $arr[$oldkey]; unset($arr[$oldkey]);

 28. What will be the output of the following code?
 <?
 echo 5 * 6 / 2 + 2 * 3;
 ?>
 Answers: • 21

 29. Does PHP 5 support exceptions?
 Answers: • Yes

No comments:

Post a Comment