Statement on glibc/iconv Vulnerability

XMLWriter::setIndent

xmlwriter_set_indent

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL xmlwriter >= 0.1.0)

XMLWriter::setIndent -- xmlwriter_set_indentActive ou non l'indentation

Description

Style orienté objet

public XMLWriter::setIndent(bool $enable): bool

Style procédural

xmlwriter_set_indent(XMLWriter $writer, bool $enable): bool

Active ou non l'indentation.

Liste de paramètres

writer

Uniquement pour les appels procéduraux. L'instance XMLWriter qui est modifiée. Cet objet provient d'un appel à xmlwriter_open_uri() ou xmlwriter_open_memory().

enable

Si l'on doit activer l'indentation ou non.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Historique

Version Description
8.0.0 writer attend une instance de XMLWriter désormais; auparavant, une resource était attendu.

Exemples

Exemple #1 XMLWriter::setIndent() et divers contenus

L'activation de l'indentation n'est pas conseillé pour le contenu diverse, car le caractère d'indentation sera aussi inséré avant les éléments en ligne.

<?php
$writer
= new XMLWriter();
$writer->openMemory();
$writer->setIndent(2);
$writer->startDocument();
$writer->startElement('p');
$writer->text('before');
$writer->writeElement('a', 'element');
$writer->text('after');
$writer->endElement();
$writer->endDocument();
echo
$writer->outputMemory();
?>

L'exemple ci-dessus va afficher :

<?xml version="1.0"?>
<p>before <a>element</a>
after</p>

Notes

Note:

L'indentation est réinitialisé quand un XMLWriter est ouvert.

Voir aussi

add a note

User Contributed Notes 1 note

up
2
info at ensostudio dot ru
3 years ago
NOTE: $enable can be integer as in example, or boolean.
To Top