Data for PHPs
Data in PHP means the structures and sources a script works with. Arrays serve as lists and dictionaries, superglobals such as $_GET, $_POST and $_SERVER carry request information, and functions read files or convert values with json_encode and json_decode. These are the daily tools for handling input and output.
Stage: Language Basics · Part of the PHP roadmap · Last reviewed 19 November 2026
What to learn in Data
- Create indexed and associative arrays and loop over them
- Transform arrays with array_map, array_filter and sorting functions
- Read form input safely from $_POST and $_GET
- Read and write files using file_get_contents and fopen
- Encode and decode JSON and check for decoding errors
Data interview questions
What are PHP superglobals?
Superglobals are built-in arrays available in every scope without declaration, such as $_GET, $_POST, $_COOKIE, $_SESSION, $_FILES and $_SERVER. They hold request data and must be treated as untrusted user input until validated.
How do you handle invalid JSON in PHP?
Pass the JSON_THROW_ON_ERROR flag to json_decode so a malformed string throws a JsonException you can catch. Without it, json_decode returns null and you must check json_last_error, which is easy to forget.
Where Data fits in the PHP roadmap
Data belongs to the Language Basics stage (beginner level), which takes about 19 hours. Syntax and data.