tidy::parseString

tidy_parse_string

(PHP 5, PHP 7, PECL tidy >= 0.5.2)

tidy::parseString -- tidy_parse_string Analyse un document HTML contenu dans une chaîne

Description

Style orienté objet

public tidy::parseString ( string $input [, mixed $config [, string $encoding ]] ) : bool

Style procédural

tidy_parse_string ( string $input [, mixed $config [, string $encoding ]] ) : tidy

Analyse un document contenu dans une chaîne.

Liste de paramètres

input

Les données à analyser.

config

La configuration config peut être passée sous forme de tableau ou de chaîne de caractères. Si une chaîne de caractères 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.

Pour une explication sur chaque option, voyez » http://tidy.sourceforge.net/docs/quickref.html.

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.

Valeurs de retour

Retourne une nouvelle instance tidy.

Exemples

Exemple #1 Exemple avec tidy::parseString()

<?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;
?>

L'exemple ci-dessus va afficher :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>
   test
  </title>
 </head>
 <body>
  <p>
   erreur<br />
   une autre ligne
  </p>
 </body>
</html>

Voir aussi