Workshop

Quiz

1: Which function is designed to allow you to set a cookie on a visitor’s browser?
2: How would you delete a cookie?
3: Which function could you use to escape a string for inclusion in a query string?
4: Which element in the $_SERVER array can contain the raw query string?
5: The name/value pairs submitted as part of a query string will be included in a built-in associative array. What is its name?

Answers

A1: The setcookie() function enables you to set a cookie (although you could also output a Set-Cookie header using the header() function).
A2: You can delete a cookie by calling setcookie() with a date that has already passed.
A3: The urlencode() function translates a string so that it can be included in a query string. ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.