|
8.131.36 tidy_parse_string()
Analyse un document HTML contenu dans une chaîne
[ Exemples avec tidy_parse_string ] PHP 5
Style procédural
tidy
tidy_parse_string (
string
input
,
mixed
config
,
string
encoding
)
Style orienté objet (méthode)
bool
tidy->parseString (
string
input
,
mixed
config
,
string
encoding
)
tidy_parse_string
analyse un document contenu dans une chaîne.
Le paramètre
config
peut
prendre la forme d'un tableau ou d'une chaîne de caractères. Sous forme
de chaîne, il représente le nom du fichier de configuration et sinon, c'est
un tableau avec les options de configuration. Lisez http://tidy.sourceforge.net/docs/quickref.php pour en savoir plus sur chaque
option.
Le paramètre
encoding
spécifie le jeu de caractères
utilisé pour les documents en entrées et sorties. Les valeurs possibles de
encoding
sont :
ascii, latin0, latin1, raw, utf8, iso2022, mac, win1252, ibm858, utf16,
utf16le, utf16be, big5 et shiftjis.
| Exemple avec tidy_parse_string |
<?php ob_start(); ?>
<html> <head> <title>test</title> </head> <body> <p>erreur<br />une autre ligne</p> </body> </html>
<?php
$buffer = ob_get_clean(); $config = array('indent' => TRUE, 'output-xhtml' => TRUE, 'wrap', 200);
$tidy = tidy_parse_string($buffer, $config, 'UTF8');
$tidy->cleanRepair();
echo $tidy; ?>
|
| Note | |
Les paramètres optionnels
config
et
encoding
ont été ajoutés en Tidy 2.0.
|
Voir aussi
tidy_parse_file
,
tidy_repair_file
et
tidy_repair_string
.
|