0

I realize that createElement() is a DOMDocument method.

If I have methods to which an element is passed, in this case, for a subsequent

element::parent::insertBefore(new_element, element)

is there a way given only the element to refer to the DomDocument so that the element can be created, an equivalent of

element::document::createElement()

or do I always need to pass the it as an additional parameter?

1 Answer 1

3

You can use:

$element->ownerDocument->createElement(...)

inherited from \DOMNode

Reference: https://php.net/manual/class.domnode.php#domnode.props.ownerdocument

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.