PHP Velho Oeste 2024

XMLReader::XML

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

XMLReader::XMLFixe les données contenant le XML à analyser

Description

public static XMLReader::XML(string $source, ?string $encoding = null, int $flags = 0): bool|XMLReader

Fixe les données contenant le XML à analyser.

Liste de paramètres

source

Chaîne de caractères contenant le XML à analyser.

encoding

L'encodage du document, ou null.

flags

Un masque de constantes LIBXML_*.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient. Si appelée statiquement, retourne un objet XMLReader ou false si une erreur survient.

Erreurs / Exceptions

This method may be called statically, but prior to PHP 8.0.0, will issue an E_DEPRECATED error in this case.

Historique

Version Description
8.0.0 XMLReader::xml() est désormais déclaré comme méthode statique, mais peut toujours être appelé sur une instance de XMLReader.

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
0
dyktus
6 years ago
If you use statically
<?php
$xmlReader
= XMLReader::xml($xmlString);
?>
You probably can receive such notice:

Non-static method XMLReader::XML() should not be called statically

Solution for this notice can be found below:
<?php
$xmlReader
= new XMLReader();
$xmlReader->xml($xmlString);
?>
To Top