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

DOMDocument::__construct

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

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

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

domdocument.construct.php

DOMDocument::__construct

класата mysqli_driver

DOMDocument::__construct Креира нов DOMDocument објект

= NULL

public DOMDocument::__construct(string $version = "1.0", string $encoding = "")

Создава нов DOMDocument object.

Параметри

version

Бројот на верзијата на документот како дел од XML декларацијата.

encoding

Кодирањето на документот како дел од XML декларацијата.

Примери

Пример #1 Креирање нов DOMDocument

<?php

$dom
= new DOMDocument('1.0', 'iso-8859-1');

echo
$dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?> */

?>

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

Белешки од корисници Управување со PDO конекции

BadGuy [at] BadGuy [dot] nl
пред 15 години
The constuctor arguments are useful if you want to build a new document using createElement, appendChild etc.

By contrast, these arguments are overriden as soon as you load a document from source by calling load() or loadXML().

* If the source contains an XML declaration specifying an encoding, that encoding is used.
* If the XML declaration does not specify an encoding, or if the source does not contain a declaration at all, UTF-8 is assumed.

This behaviour applies no matter what you declared when you called new DOMDocument().
jarl kringelding skim punt com
пред 18 години
Be aware using the encoding parameter in the constructor.
It does not mean that all data is automatically encoded for you in the supplied encoding. You need to do that yourself once you choose an encoding other than the default UTF-8. See the note on DOM Functions on how to properly work with other encodings...

The constructor example clearly shows that version and encoding only end up in the XML header.
dave at revlob dot com
пред 18 години
@Jarl

Not sure if this is what you meant when you said "The constructor example clearly shows that version and encoding only end up in the XML header", but you can also affect other parameters in the generated XML header, by accessing the DOMDocument's properties, for example:

<?php

$dom = new DOMDocument('1.0', 'UTF-8');
$dom->xmlStandalone = false;
echo $dom->saveXML();

// <?xml version="1.0" encoding="UTF-8" standalone="no"?>
bholbrook at servillian dot com
пред 18 години
Make sure that php_domxml.dll on windows is removed before using the domdocument class as they cannot coexist.
blackhailang at gmail dot com
пред 17 години
domdocument::domdocument() expects at least
At the least, I found that It due to ZEND optimizer, uninstall it,working well, but the speeds will be slowlly :-(.

Comment :
item 1 : 2008-10-03 17:10:58, gkrong said: 
"Warning: domdocument::domdocument() expects at least 1
 parameter"
If you use PHP 5 in windows, you don't need to declare
php_domxml.dll in your php.ini file. 
so u can give comment in the line php_domxml.dll in your
php.ini file. 
you only need to comment it out, but do not delete the
php_domxml.dll file in the ext directory.
christian dot reinecke на web dot de
пред 17 години
If you get the error message "domdocument::domdocument() expects parameter 2 to be long, string given"  for a code sample like this:

$dom = new DOMDocument('1.0', 'UTF-8');
$dom->xmlStandalone = false;
echo $dom->saveXML();

which is obviously correct if you compare the constructor signature:

__construct  ([ string $version  [, string $encoding  ]] )

make sure you're not overwritting this dom library by another (f.e. extension=php_domxml.dll in php.ini). XAMPP f.e. delivers its standard version with php_domxml.dll which ends up in this error message
steve на mrclay точка org
пред 17 години
To expand on bholbrook's comment, if you receive this: "Warning: domdocument::domdocument() expects at least 1 parameter", it is due to the old domxml extension, which you need to disable.

domxml overwrites DOMDocument::_construct with an alias to domxml_open_mem, so this code:
<?php
$doc = new DOMDocument();
?>
...essentially does this:
<?php
$dom = domxml_open_mem();
?>
...which is why PHP complains about expecting at least 1 parameter (it expects a string of XML).
На оваа страница

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

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

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

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

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