php8.5
Home/ Manual/ dom / htmldocument/ Dom\HTMLDocument::createFromFile

Dom\HTMLDocument::createFromFile

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Parses an HTML document from a file

Description

Dom\HTMLDocument::createFromFile(string $path, int $options = 0, string|null $overrideEncoding = null): Dom\HTMLDocument

Parses an HTML document from a file, according to the living standard.

Parameters

path

The path to the file to parse.

options

Options

overrideEncoding

Encoding

Return Values

The parsed document as an Dom\HTMLDocument instance.

Errors/Exceptions

  • Throws a ValueError if path contains null bytes or contains "%00".
  • Throws an Exception if the file could not be opened.

Whitespace

See Also

  • Dom\HTMLDocument::createEmpty
  • Dom\HTMLDocument::createFromString

Source: reference/dom/dom/htmldocument/createfromfile.xml · from the official PHP manual (php/doc-en)