Please Select a Company.
Please Select a Company.
Php MCQ Questions | Interview Quick

.

Php MCQ

1. Which is the most secure way to avoid storing a password in clear text in database?

2. In a conditional statement, you want to execute the code only if both value are true. Which comparison operator should you use?

3. All variables in PHP start with which symbol?

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

5. 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.

6. Which are valid PHP error handling keywords?

7. . Which value equates to true?

8. . What is the purpose of adding a lowercase "u" as a modifier after the final delimiter in a Perl-compatible regular expression?

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

10. . Which is the correct format for adding a comment to a PHP script?

11. 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?

12. The ignore_user_abort( ) function sets whether a client disconnect should abort a script execution. In what scenario would you, as a web developer, use this function?

13. 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?

14. Which PHP script uses a constructor to display the string "Winter is almost over!"?

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

16. Which line could you NOT use to comment out "Space: the final frontier"?

17. What displays in a browser when the following code is written?

18. Which operator would you use to find the remainder after division?

19. Assuming the Horse class exists, which is a valid example of inheritance in PHP?

20. 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 _

21. Your php page is unexpectedly rendering as totally blank. Which step will shed light on the problem?

22. Both self and this are keywords that can be used to refer to member variables of an enclosing class. The difference is that $this->member should be used for ** members and self::$member should be used for ** members.

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

24. What is the cause of 'Cannot modify header information - headers already sent'?

25. Which php control structure is used inside a loop to skip the rest of the current loops code and go back to the start of the loop for the next iteration

26. The php not operator is !. Given the snippet, is there an out put and what is it?

27. You want to list the modules available in your PHP installation. What command should you run?

28. What is the job of the controller as a component in MVC?

29. 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.

30. Assuming that $first_name and $family_name are valid strings, which statement is invalid?

31. Which code snippet demonstrates encapsulation?

32. When it comes to the value of a variable, what is the difference between NULL and empty?

33. 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 ** ?

34. Why should you follow a PSR standard?

35. What are getters and setters?

37. Which PHP variable name is invalid?

38. Which command will extract the domain suffix ("com") from the string $string = "https://cat-bounce.com";?

39. Where is PHP code executed?

40. Which is not a valid magic constant?

41. Imagine a web application, built following a 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?

42. Which script might be used to continue a user's search for music, across different webpages?

43. Which PHP script finds the earliest and latest dates from an array?

44. In PHP 7, What is the correct way to import multiple classes from namespace in a single declaration ?!

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

46. What type of computer language is PHP?

47. Which superglobal variable holds information about headers, paths, and script locations?

48. DRY (Don't Repeat Yourself) is a principle of software development aimed at reducing repetition of software patterns. Which choice is not a way to write DRYer code with PHP?

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

50. Your site must allow uploading of large files. What might you need to do?

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

52. What is the correct way to include the file gravy.php in the middle of HTML code?

53. Which two functions can sanitize text and validate text formats?

55. You want to use wildcard characters when searching for records in a MySQL/MariaDB database using a PDO prepared statement. Which code should you use?

56. Assume that $r is 255, and $g and $b are both 0. What is the correct code to output "#ff0000"?

57. You want to find out what day Twelfth Night falls on after Christmas 2018. Which code should you use?

58. Which loop displays all numbers from 1 to 10 inclusive?

59. Which are types of control structures in PHP?

60. Which function can you use in error handling to stop the execution of a script and is equivalent to exit()?

61. Which is not true of the toString() in PHP?

62. What is a generator and how is it used in PHP?

63. Can you extend a final defined class?

-->

64. How can you test if a checkbox is set?

65. A form to subscrive to a newsletter is submitted using the POST method. The form has only one field: an input text field named "email". How would you check if the field is empty and, if it is, print "The email cannot be empty"?

66. What is the PHP fatal error type?

67. Which script properly validates the IP address given?

68. You have an online form with a file input field called "image" for uploading files. Assuming the path to the upload directory is $path, which code should you use to make sure the file is uploaded from your form to the correct location?

Our Brands by Nishtya Infotech Private Limited:

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as