PHP 8.4.3 Released!

Dom\HTMLDocument::createFromFile

(PHP 8 >= 8.4.0)

Dom\HTMLDocument::createFromFileParses an HTML document from a file

Beschreibung

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

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

Parameter-Liste

path
The path to the file to parse.
options

Bitweises OR von libxml-Konstanten für weitere Optionen.

It is also possible to pass Dom\HTML_NO_DEFAULT_NS to disable the use of the HTML namespace and the template element. This should only be used if the implications are properly understood.
overrideEncoding
The encoding that the document was created in. If not provided, it will attempt to determine the encoding that is most likely used.

Rückgabewerte

The parsed document as an Dom\HTMLDocument instance.

Fehler/Exceptions

  • Throws a ValueError if path contains null bytes or contains "%00".
  • Throws a ValueError if options contains an invalid option.
  • Throws a ValueError if overrideEncoding is an unknown encoding.
  • Throws an Exception if the file could not be opened.

Anmerkungen

Hinweis: Whitespace in the html and head tags is not considered significant and may lose formatting.

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top