(PHP 5, PHP 7, PHP 8, PECL tidy >= 0.7.0)
tidy::repairString -- tidy_repair_string — Répare une chaîne HTML en utilisant un fichier de configuration optionnel
Style orienté objet
$string, array|string|null $config = null, ?string $encoding = null): string|falseStyle procédural
$string, array|string|null $config = null, ?string $encoding = null): string|falseRépare la chaîne fournie.
stringLes données à réparer.
config
La configuration config peut être passée
sous forme de array ou de string. Si une string est passée,
elle est interprétée comme le nom du fichier de configuration,
et sinon, elle est interprétée comme les options elles-mêmes.
Consulter » http://api.html-tidy.org/#quick-reference pour une explication sur chaque option.
encoding
Le paramètre encoding configure l'encodage
pour les documents d'entrée et de sortie. Les valeurs possibles sont
ascii, latin0, latin1,
raw, utf8, iso2022,
mac, win1252, ibm858,
utf16, utf16le, utf16be,
big5 et shiftjis.
Retourne la chaîne réparée, ou false si une erreur survient.
| Version | Description |
|---|---|
| 8.0.0 | tidy::repairString() est désormais une méthode statique. |
| 8.0.0 |
config et encoding sont désormais nullables.
|
| 8.0.0 |
Cette fonction n'accepte plus le paramètre useIncludePath.
|
Exemple #1 Exemple avec tidy::repairString()
<?php
ob_start();
?>
<html>
<head>
<title>test</title>
</head>
<body>
<p>error</i>
</body>
</html>
<?php
$buffer = ob_get_clean();
$tidy = tidy_repair_string($buffer);
echo $tidy;
?>L'exemple ci-dessus va afficher :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>test</title> </head> <body> <p>error</p> </body> </html>