PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

tidy_repair_file> <tidy_parse_file
Last updated: Fri, 11 Apr 2008

view this page in

tidy_parse_string

(PHP 5, PECL tidy:0.5.2-1.2)

tidy_parse_string — Analyse un document HTML contenu dans une chaîne

Description

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.html 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 #1 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;
?>

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>
      error<br />
      another line
    </p>
  </body>
</html>

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().



add a note add a note User Contributed Notes
tidy_parse_string
There are no user contributed notes for this page.

tidy_repair_file> <tidy_parse_file
Last updated: Fri, 11 Apr 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites