Importing User Input into Global Scope

It is possible, but not recommended, to import fields from a form submission into global variables. This behavior was once the default for PHP. Although it was useful for quick scripts, it represented a security risk, with the prospect of user-submitted values overwriting script variables. You can change the new default by altering the php.ini file. You can also import user input explicitly with the import_request_variables() function. This function requires a string representing the types to import and another optional but advisable string that adds a prefix to all imported variable names. The types argument can be any combination of g, p and c, standing for get, post, and cookies, respectively. If you ...

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.