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

search for in the

tidy::root> <tidy::repairFile
[edit] Last updated: Fri, 10 Feb 2012

view this page in

tidy::repairString

tidy_repair_string

(PHP 5, PECL tidy >= 0.7.0)

tidy::repairString -- tidy_repair_string別途提供される設定ファイルを使用して文字列を修正する

説明

オブジェクト指向型

string tidy::repairString ( string $data [, mixed $config [, string $encoding ]] )

手続き型

string tidy_repair_string ( string $data [, mixed $config [, string $encoding ]] )

与えられた文字列を修正します。

パラメータ

data

修正するデータ。

config

config には配列あるいは文字列を渡します。 文字列を渡した場合は設定ファイルの名前、 それ以外の場合は設定そのものとして解釈されます。

オプションについての説明は » http://tidy.sourceforge.net/docs/quickref.html を参照ください。

encoding

encoding は入出力ドキュメントのエンコーディングを設定します。 指定できるエンコーディング名は asciilatin0latin1rawutf8iso2022macwin1252ibm858utf16utf16leutf16bebig5 および shiftjis です。

返り値

修正した文字列を返します。

例1 tidy::repairString() の例

<?php
ob_start
();
?>

<html>
  <head>
    <title>test</title>
  </head>
  <body>
    <p>error</i>
  </body>
</html>

<?php

$buffer 
ob_get_clean();
$tidy = new tidy();
$clean $tidy->repairString($buffer);

echo 
$clean;
?>

上の例の出力は以下となります。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>test</title>
</head>
<body>
<p>error</p>
</body>
</html>

注意

注意: オプションのパラメータ config_optionsenconding は Tidy 2.0 で追加されました。

参考



add a note add a note User Contributed Notes tidy::repairString
dan-dot-hunsaker-at-gmail-dot-com 16-Jul-2011 04:49
The docs referenced at http://tidy.sourceforge.net/docs/quickref.html above state that the configuration option 'sort-attributes' is an enumeration of 'none' and 'alpha', thereby specifying that strings of either form are the acceptable values.  This may not be the case, however - on my system, the option was not honored until I set it to true.  This may also be the case with other options, so experiment a bit.  The output of tidy::getConfig() may be useful in this regard.
gnuffo1 at gmail dot com 23-Aug-2010 05:44
You can also use this function to repair xml, for example if stray ampersands etc are breaking it:

<?php
$xml
= tidy_repair_string($xml, array(
   
'output-xml' => true,
   
'input-xml' => true
));
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites