Advanced PHP Quiz

1. Why is the use of mysql_real_escape_string() so important?

It Protects Against SQL Injection Attacks

It Escapes Special Characters

It Reduces The Possibility of Malicious Code Being Executed

It Makes User Input Data Harmless When Added Into a Query

All of These Options Are Correct


2. Which function will return the number of rows affected by a query, regardless of the type of query?

mysql_affected_rows()

mysql_num_rows()


3. Which function will return a URL to you in segments?

get_headers()

urldecode()

get_meta_tags()

parse_url()

urlencode()


4. When opening a file with the fopen() function, which option will open a file for writing only, and place the pointer at the end of the file?

r+

w

w+

c

a


Bonus Question: David's father had three sons: Snap, Crackle, and ?

David

Pop

Gurgle

Peter

Hop


5. Which function will return query results as an enumerated array?

mysql_fetch_array()

mysql_fetch_assoc()

mysql_fetch_lengths()

mysql_fetch_object()

mysql_fetch_row()


6. What is the limit of form data that can be transferred via $_GET[] and $_POST[], respectively?

25 Characters & 2MB

50 Characters & 4MB

100 Characters & 8MB

200 Characters & 16MB

100 Characters & 4MB


7. The (fill in the blank) must be specified in the header() function before any other output is sent to the browser.

Image-type

Content-type

Header-type


8. The imagecreate() function is used to draw a border around an image.

True

False


9. Which image function is used to assign colors?

imagegif()

imagefilltoborder()

imagecreatetruecolor()

imagecreate()

imagecolorallocate()


10. Which function will read an opened file one line at a time?

fread()

fgets()

feof()

filesize()


11. Should checkbox names be unique, or should radio button names be unique?

Checkbox Names Should Be Unique to Each Checkbox (Radio Button Names Should Be Identical)

Radio Button Names Should Be Unique to Each Radio Button (Checkbox Names Should Be Identical)


12. Which PHP functions are used to open and close a MYSQL connection?

mysql_open() & mysql_close()

mysql_open() & mysql_disconnect()

mysql_connect() & mysql_close()

mysql_connect() & mysql_disconnect()


Bonus Question: What has one head, one foot and four legs?

A Giraffe

A Centipede

A Bed

A Pumpkin

A Clock


13. What is the difference between the $_GET[] and $_POST[] superglobals?

$_GET[] Sends Form Data Via the URL and $_POST[] Sends Form Data Behind-the-Scenes

$_POST[] Sends Form Data Via the URL and $_GET[] Sends Form Data Behind-the-Scenes


14. What data is stored in the $_SERVER['REMOTE_ADDR'] superglobal?

The Server's IP Address

The Visitor's IP Address

The Visitor's Mailing Address

The Visitor's MAC Address


15. What is stored in the visitor's browser, can be edited by the visitor and can last years?

Sessions

Segments

Cookies

Cupcakes