Skip to content

Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity #16807

@askonomm

Description

@askonomm

Description

The following code:

<?php

$dom = HTMLDocument::createFromString('<p>hello</p>', HTML_NO_DEFAULT_NS);

Resulted in this output:

Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity

But I expected this output instead:

It to work normally, given that it gets a perfectly valid piece of HTML. It doesn't break the HTML parsing, so it seems to work, but for some reason throws a warning.

PHP Version

PHP 8.4.0 RC1

Operating System

Debian 12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions