Test your knowledge of PHP scripting topics

Posted on
Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone

How much do you know about PHP scripting? Would you like to know more?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?
A. high()
B. greatest()
C. max()
D. ceiling()

2. As purchases are made, you need your program to remove items from an array. Which function can be used to accomplish this?
A. remove()
B. unset()
C. delete()
D. unarray()

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?
A. NumberFormatter
B. MoneyMaker
C. CurrencyDisplay
D. DollarsCents

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?
A. instr()
B. strpos()
C. str_find()
D. within()

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?
A. fprint()
B. printf()
C. printif()
D. assert()

6. In PHP, the basic regular expression function is:
A. regexpr()
B. regexp()
C. preg_match()
D. grep()

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?
A. hash_file()
B. md5_file()
C. file_md5()
D. hash_md5()

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)?
A. file()
B. fread()
C. fline()
D. fgets()

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)?
A. #
B. /#
C. //
D. *
E. /*

10. When you are done using an output buffer, what can you use to make a user’s browser update with new content?
A. flush()
B. empty()
C. clear()
D. drain()

11. With PHP, before you can add any variables to a session, you must first call which function?
A. INT()
B. _ _BEGIN_ _
C. session_start()
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?
A. three
B. two
C. one
D. none

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?
A. is_numeric()
B. is_number()
C. is_integer()
D. is_not_string()

14. Which of the following PHP functions convers a binary number into a decimal number?
A. chr()
B. base_convert()
C. bindec()
D. dec_from_bin()

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.


 

ANSWERS
1. C
2. B
3. A
4. B
5. D
6. C
7. B
8. B and D
9. A, C and E
10. A
11. C
12. A
13. A
14. C
15. A

Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone
Emmett Dulaney

ABOUT THE AUTHOR

Emmett Dulaney is an associate professor and the author of numerous certification study guides, including the CompTIA A+ Complete Deluxe Study Guide, Second Edition (ISBN: 978-1-118324066).

Posted in Tech Know|

Comment:

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>