Documentation

DOMDocumentBadInit extends DOMDocument
in package

This is the main class which builds on top of PHP's native DOMDocument

Table of Contents

OPTION_DISABLE_HTML_NS  = 2
OPTION_EVALUATE_PHP  = 1
UNDEFINED  = "b0814351-6e51-4134-a77b-8e5fbec4e026"
$constructorCalled  : mixed
__call()  : mixed
Magic method for function calls, this can be used to call any methods supported by DOMElement on the documentElement of this document
__construct()  : mixed
Constructor for the DOMDocument
__get()  : mixed
Magic method for getting properties. Only "html" is supported presently.
__toString()  : string
Returns the entire document as a string.
convertUTF8ToHTMLEntities()  : string
Converts UTF8 characters to their HTML entity equivalents
create()  : DOMObject
Creates a HTML fragment from the supplied HTML source string
getDocumentElementSafe()  : DOMElement
Function to safely get the document element. Some PHP builds do not implement documentElement, this function can be used to safely retrieve the document element in absense of this property.
import()  : DOMObject
This function will import the specified content to be used inside this document.
load()  : This
Loads the named file
loadHTML()  : bool
Loads the supplied HTML string
loadHTMLFile()  : bool
Loads the supplied HTML file
save()  : int|false
Saves the entire document as HTML5, into the specified file.
saveHTML()  : string|false
Saves the whole document, or specified element, as a HTML string
saveInnerBody()  : string
This function saves only the inside of the <body> element of this document. This is useful when you want to import a HTML document into another, but you don't want to end up with nested <html> elements. This is equivalent to using the "html" property.
shorthand()  : callable
Returns a "shorthand" function which you can use in a jQuery-like manner to create fragemnts, eg $_ = $doc->shorthand(); $div = $_("<div>Example</div>);
onLoaded()  : null
Callback which fires after the HTML has been parsed and loaded, but before loadHTML returns. Useful for controlling the execution order for operations spread across an inheritance chain.

Constants

OPTION_DISABLE_HTML_NS

public mixed OPTION_DISABLE_HTML_NS = 2

OPTION_EVALUATE_PHP

public mixed OPTION_EVALUATE_PHP = 1

UNDEFINED

public mixed UNDEFINED = "b0814351-6e51-4134-a77b-8e5fbec4e026"

Properties

$constructorCalled

private mixed $constructorCalled = false

Methods

__call()

Magic method for function calls, this can be used to call any methods supported by DOMElement on the documentElement of this document

public __call(mixed $name, mixed $arguments) : mixed
Parameters
$name : mixed
$arguments : mixed
Tags
see
DOMElement

for a list of supported methods

Return values
mixed

__construct()

Constructor for the DOMDocument

public __construct() : mixed
Return values
mixed

__get()

Magic method for getting properties. Only "html" is supported presently.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__toString()

Returns the entire document as a string.

public __toString() : string
Return values
string

The entire document rendered to a string

convertUTF8ToHTMLEntities()

Converts UTF8 characters to their HTML entity equivalents

public static convertUTF8ToHTMLEntities(string $html) : string
Parameters
$html : string

A HTML string to perform conversion on

Return values
string

The converted HTML string

create()

Creates a HTML fragment from the supplied HTML source string

public create(string $html) : DOMObject
Parameters
$html : string

The HTML source string

Return values
DOMObject

The resulting element(s)

getDocumentElementSafe()

Function to safely get the document element. Some PHP builds do not implement documentElement, this function can be used to safely retrieve the document element in absense of this property.

public getDocumentElementSafe() : DOMElement
Return values
DOMElement

The document element for this document

import()

This function will import the specified content to be used inside this document.

public import(mixed $subject) : DOMObject
Parameters
$subject : mixed

The subject, a HTML fragment string, DOMElement from another document, or another DOMDocument.

Return values
DOMObject

The resulting element(s)

load()

Loads the named file

public load(string $filename[, int $options = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS ]) : This
Parameters
$filename : string
$options : int = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS

A bit field of options. Presently only DOMDocument::OPTION_EVALUATE_PHP is supported, this defaults to TRUE and will execute inline PHP

Tags
see
https://github.com/Masterminds/html5-php#options

for other options supported by the HTML5 parser

Return values
This

document, for method chaining

loadHTML()

Loads the supplied HTML string

public loadHTML(string $src[, int $options = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS ]) : bool
Parameters
$src : string

The HTML string to parse

$options : int = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS

A bit field of options. Presently only DOMDocument::OPTION_EXECUTE_PHP is supported, this defaults to TRUE and will execute inline PHP

Tags
see
https://github.com/Masterminds/html5-php#options

for other options supported by the HTML5 parser

Return values
bool

true

loadHTMLFile()

Loads the supplied HTML file

public loadHTMLFile(string $filename[, int $options = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS ]) : bool
Parameters
$filename : string

The file to parse

$options : int = DOMDocument::OPTION_EVALUATE_PHP | DOMDocument::OPTION_DISABLE_HTML_NS

A bit field of options. Presently only DOMDocument::OPTION_EXECUTE_PHP is supported, this defaults to TRUE and will execute inline PHP

Tags
see
https://github.com/Masterminds/html5-php#options

for other options supported by the HTML5 parser

Return values
bool

true

save()

Saves the entire document as HTML5, into the specified file.

public save(string $filename[, array<string|int, mixed> $options = array() ]) : int|false
Parameters
$filename : string

The name of the file to save to

$options : array<string|int, mixed> = array()

An array of options to pass to the HTML5 parser

Tags
see
https://github.com/Masterminds/html5-php#options

for other options supported by the HTML5 parser

Return values
int|false

saveHTML()

Saves the whole document, or specified element, as a HTML string

public saveHTML([mixed $element = null ][, array<string|int, mixed> $options = array() ]) : string|false
Parameters
$element : mixed = null
$options : array<string|int, mixed> = array()

An array of options to pass to the HTML5 parser

Tags
see
https://github.com/Masterminds/html5-php#options

for other options supported by the HTML5 parser

Return values
string|false

saveInnerBody()

This function saves only the inside of the <body> element of this document. This is useful when you want to import a HTML document into another, but you don't want to end up with nested <html> elements. This is equivalent to using the "html" property.

public saveInnerBody() : string
Return values
string

The HTML string

shorthand()

Returns a "shorthand" function which you can use in a jQuery-like manner to create fragemnts, eg $_ = $doc->shorthand(); $div = $_("<div>Example</div>);

public shorthand() : callable
Return values
callable

A convenience function which creates HTML fragments from a string

onLoaded()

Callback which fires after the HTML has been parsed and loaded, but before loadHTML returns. Useful for controlling the execution order for operations spread across an inheritance chain.

protected onLoaded() : null
Return values
null

Search results