PHP.mk документација

DOMImplementation::createDocument

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

domimplementation.createdocument.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека domimplementation.createdocument.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
DOMImplementation::createDocument

Референца за `domimplementation.createdocument.php` со подобрена типографија и навигација.

domimplementation.createdocument.php

DOMImplementation::createDocument

класата mysqli_driver

DOMImplementation::createDocument Creates a DOMDocument object of the specified type with its document element

= NULL

public DOMImplementation::createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument

Креира DOMDocument object of the specified type with its document element.

Параметри

namespace

The namespace URI of the document element to create.

qualifiedName

The qualified name of the document element to create.

doctype

The type of document to create or null.

Вратени вредности

Нов DOMDocument object. If namespace, qualifiedNameПрепорачаниот начин за избегнување на SQL инјекција е со врзување на сите податоци преку подготвени изрази. Користењето на параметризирани прашања не е доволно за целосно избегнување на SQL инјекција, но тоа е најлесниот и најбезбедниот начин за обезбедување влез во SQL изразите. Сите динамични литерали на податоци во doctype are null, the returned DOMDocument is empty with no document element.

Errors/Exceptions

Може да фрли DOMException со следните кодови за грешки:

DOM_WRONG_DOCUMENT_ERR

Покренато ако doctype has already been used with a different document or was created from a different implementation.

DOM_NAMESPACE_ERR

Се крева ако има грешка со именскиот простор, како што е утврдено од namespace and qualifiedName.

Дневник на промени

Верзија = NULL
8.4.0 The function now has the tentative return type DOMDocument.
8.0.3 namespace сега е null.
8.0.0 doctype сега е null.
8.0.0 Повикувањето на оваа функција статички сега ќе фрли Грешка. Претходно, а E_DEPRECATED беше кренат.

Види Исто така

Белешки од корисници 3 белешки

eboyjr
пред 15 години
To add on to the other example, here's how to create an XHTML 1.0 transitional document with head, title, and body elements.

<?php

$document = DOMImplementation::createDocument(null, 'html',
    DOMImplementation::createDocumentType("html", 
        "-//W3C//DTD XHTML 1.0 Transitional//EN", 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"));
$document->formatOutput = true;

$html = $document->documentElement;
$head = $document->createElement('head');
$title = $document->createElement('title');
$text = $document->createTextNode('Title of Page');
$body = $document->createElement('body');

$title->appendChild($text);
$head->appendChild($title);
$html->appendChild($head);
$html->appendChild($body);

echo $document->saveXML();
?>

This outputs: (http links removed due to spam)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "doctype.dtd"> 
<html xmlns="w3org1999xhtml"> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Title of Page</title> 
  </head> 
  <body></body> 
</html> 

Note the saveXML function. If saveHTML was used instead, you get the output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "doctype.dtd"> 
<html> 
<head><title>Title of Page</title></head> 
<body></body> 
</html>
arturm at union dot com dot pl
19 години пред
To create HTML document with doctype:

<?php
$doctype = DOMImplementation::createDocumentType("html",
                "-//W3C//DTD HTML 4.01//EN",
                "http://www.w3.org/TR/html4/strict.dtd");
$doc = DOMImplementation::createDocument(null, 'html', $doctype);
?>
sleistico at gmail dot com
пред 7 години
I just recently got an error, having to do with deprecation, by using the type of calls in the other example listed here.  What I had to do instead looks like this...

$htmldoc = (new DOMImplementation)->createDocument(null, 'html', (new DOMImplementation)->createDocumentType("html"));

This creates a document with <!DOCTYPE html> at the top of it.
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.