Rapide Advanced Adulte
   tidy_parse_string   
Resultatstidy_parse_string   |   Contact

     Manuel PHP     
Partager
 
 
Partager
Partager

 

Table :

.ob tidyhandler
.tidy access count
.tidy clean repair
.tidy config count
.tidy:: construct
.tidy diagnose
.tidy error count
.tidy get body
.tidy get config
.tidy get error buffer
.tidy get head
.tidy get html ver
.tidy get html
.tidy get opt doc
.tidy get output
.tidy get release
.tidy get root
.tidy get status
.tidy getopt
.tidy is xhtml
.tidy is xml
.tidy load config
.tidy node->get attr
.tidy node->get nodes
.tidy node->next
.tidy node->prev
.tidy parse file
.tidy parse string
.tidy repair file
.tidy repair string
.tidy reset config
.tidy save config
.tidy set encoding
.tidy setopt
.tidy warning count
.tidyNode->hasChildren
.tidyNode->hasSiblings
.tidyNode->isAsp
.tidyNode->isComment
.tidyNode->isHtml
.tidyNode->isJste
.tidyNode->isPhp
.tidyNode->isText
 
   

  tidy_parse_string  


tidy_parse_string

(PHP 5)

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


    Annonces       
 

 Retour au chapitre Php

 

Top
 

Ajouter JungleKey.fr à votre Explorateur

 
 

About Us | © 2007 JungleKey




iBlack | Mobile | Wiki | Ajouter ce moteur