XMLWriter::text
xmlwriter_text
(PHP 5 >= 5.1.2, PHP 7, PECL xmlwriter >= 0.1.0)
XMLWriter::text -- xmlwriter_text — Записать текст
Описание
Объектно-ориентированный стиль
bool XMLWriter::text
( string
$content
)Процедурный стиль
bool xmlwriter_text
( resource
$xmlwriter
, string $content
)Записывает текст.
Список параметров
-
xmlwriter
-
Только для процедурных вызовов. Изменяемый resource XMLWriter. Этот ресурс может быть получен из xmlwriter_open_uri() или xmlwriter_open_memory().
-
content
-
Содержимое текста.
Возвращаемые значения
Возвращает TRUE
в случае успешного завершения или FALSE
в случае возникновения ошибки.
- XMLWriter::endAttribute
- XMLWriter::endCData
- XMLWriter::endComment
- XMLWriter::endDocument
- XMLWriter::endDTDAttlist
- XMLWriter::endDTDElement
- XMLWriter::endDTDEntity
- XMLWriter::endDTD
- XMLWriter::endElement
- XMLWriter::endPI
- XMLWriter::flush
- XMLWriter::fullEndElement
- XMLWriter::openMemory
- XMLWriter::openURI
- XMLWriter::outputMemory
- XMLWriter::setIndentString
- XMLWriter::setIndent
- XMLWriter::startAttributeNS
- XMLWriter::startAttribute
- XMLWriter::startCData
- XMLWriter::startComment
- XMLWriter::startDocument
- XMLWriter::startDTDAttlist
- XMLWriter::startDTDElement
- XMLWriter::startDTDEntity
- XMLWriter::startDTD
- XMLWriter::startElementNS
- XMLWriter::startElement
- XMLWriter::startPI
- XMLWriter::text
- XMLWriter::writeAttributeNS
- XMLWriter::writeAttribute
- XMLWriter::writeCData
- XMLWriter::writeComment
- XMLWriter::writeDTDAttlist
- XMLWriter::writeDTDElement
- XMLWriter::writeDTDEntity
- XMLWriter::writeDTD
- XMLWriter::writeElementNS
- XMLWriter::writeElement
- XMLWriter::writePI
- XMLWriter::writeRaw
Коментарии
Note that $content is automatically sanitized/escaped:
> into >
< into <
& into &
" into "
However, single quotes stay unescaped! This is major drawback, if you're creating sitemaps. You need to escape ' into ' before passing it to XMLWriter::text or XMLWriter::writeElement or extend the XMLWriter class.
Corrected previous comment!
Note that $content is automatically sanitized/escaped:
> into >
< into <
& into &
" into "
However, single quotes stay unescaped! This is major drawback, if you're creating sitemaps. To fix that and to prevent double escaping, you will need to use XMLWriter::writeRaw or extend the XMLWriter class and escape the content yourself with i.e.
<?php
$content = htmlspecialchars($content, ENT_QUOTES | ENT_XML1, 'UTF-8');
?>
XMLWriter::text or XMLWriter::writeElement would double escape ' and result in &apos;