Parse

To parse, or parsing, refers to the process of analyzing and interpreting the structure of a data to extract meaningful information.

PHP has a phase of parsing: it is handled by the tokenizer, a part of the PHP engine, that reads the text file with the source code, and outputs the atomic blocks it understood, or a Fatal error.

Parsing is commonly used when working with data formats like XML, JSON, HTML, YAML, or even custom text formats. It involves breaking down a string into its individual components or tokens to understand its underlying structure.

The simplest usage of parsing is to identify errors in the structure, leading to an early aborting of the processing.

<?php

if (!json_validate($json)) {
    throw new Exception('invalid JSON data');
}

$object = json_decode($json);

?>

Documentation

See also Parse, don’t validate.

Related : Sanitation, Validation, parse_str(), ParseError, Parser, Phptoken, Lint, Won’t Execute, parse_url()