Superglobal Variables

Before you actually build a form and use it to acquire data, we need to make a small detour and look at superglobal variables. We first met global variables in Hour 6, “Functions.” A global variable is any variable declared at the “top level” of a script—that is, declared outside a function. Superglobal variables are arrays built in to PHP. They are populated for you automatically with useful elements, and they are available in any scope. You can access a superglobal array within a function or method without using the global keyword. We will encounter superglobal variables throughout the rest of this book. Table 10.1 provides a summary.

Table 10.1. PHP Superglobal Arrays
ArrayDescription
$_COOKIEContains keys and values set ...

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.