One of the most popular server-side scripting languages is PHP. Originally the brainchild of programmer Rasmus Lerdorf, PHP is great for embedding in HTML and has become one of the most widely used free programming languages in the last 20 years.
All of this begs the question of any web-aligned IT professional: How well do you know this language that you are likely interact with on a regular basis? What follows is a self-test of 25 questions based on topics ranging from trivial to complicated.
The answers appear at the end of the questions. Good luck!
1. You want your code to be able to find the oldest employee in the database and identify them. The database is an array and age is one of the fields in that array. On this field, which function should be used?
2. As purchases are made, you need your program to remove items from an array. Which function can be used to accomplish this?
3. The shopping cart code you’ve written needs to display numbers as monetary values to indicate that the almost twenty dollars the user is close to spending is “$19.95”. Which class can be used to accomplish this?
4. You need to use a function to check and make sure the value a user enters is an email address and thus contains a period (.). What function can be used to look within a string for a substring?
5. You are trying to debug your code before it goes live this weekend. Which function can be used in place of print() to generate messages if conditions are not true?
6. In PHP, the basic regular expression function is:
7. You need to make sure that a file the user uploads from within your program does not become corrupted in the transfer process. Which of the following functions can be used to return an MD5 hash that can be used as a checksum?
8. Which of the following functions in PHP can be used to read a large file line-by-line or piece-by-piece (choose two)?
9. You are needing to modify some PHP code written by a former employee and want to start the job by reading all of this comments. Within PHP, which of the following can be used to mark the start of comments within the code (select all correct answers)?
10. When you are done using an output buffer, what can you use to make a user’s browser update with new content?
11. With PHP, before you can add any variables to a session, you must first call which function?
B. _ _BEGIN_ _
D. None. You do not need to first call any function before you start adding variables
12. The setcookie() function in PHP requires how many parameters?
13. You need to make sure that the user using your HTML-based form enters a number for the variable asking them their age. Which of the following will return a value of TRUE if the variable contains a number?
14. Which of the following PHP functions convers a binary number into a decimal number?
15. From a logic standpoint, which of the following is true of the XOR operator?
A. It is true if either $a or $b is true but false if both $a and $b are true
B. It is true if either $a and/or $b is true
C. It is true only if both $a and $b are true
D. It is true only if $a and $b are not true
Please visit GoCertify to attempt the remaining 10 questions of this quiz.
8. B and D
9. A, C and E
The post Test your knowledge of Php Scripting Topics appeared first on Certification Magazine.