XMLWriter::text
(PHP 5 >= 5.1.2, PECL xmlwriter:0.1-2.0.4)
XMLWriter::text — Write text
Описание
Object oriented style:
XMLWriter
bool text
( string $content
)
Procedural style:
bool xmlwriter_text
( resource $xmlwriter
, string $content
)
Writes a text.
Список параметров
- xmlwriter
-
Only for procedural calls. The XMLWriter resource that is being modified. This resource comes from a call to xmlwriter_open_uri() or xmlwriter_open_memory().
- content
-
The contents of the text.
Возвращаемые значения
Возвращает 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;