tidy::repairString

tidy_repair_string

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

tidy::repairString -- tidy_repair_stringRepair a string using an optionally provided configuration file

说明

面向对象风格

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

过程化风格

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

Repairs the given string.

参数

data

The data to be repaired.

config

The config config can be passed either as an array or as a string. If a string is passed, it is interpreted as the name of the configuration file, otherwise, it is interpreted as the options themselves.

Check » http://tidy.sourceforge.net/docs/quickref.html for an explanation about each option.

encoding

The encoding parameter sets the encoding for input/output documents. The possible values for encoding are: ascii, latin0, latin1, raw, utf8, iso2022, mac, win1252, ibm858, utf16, utf16le, utf16be, big5, and shiftjis.

返回值

Returns the repaired string.

范例

Example #1 tidy::repairString() example

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

参见

相关文章
php domdocument dumps the internal document into a string using html formattingphp domdocument dumps the internal document into a file using html formattingphp enchant 函数 creates a dictionary using a pwl filephp radius 函数 causes the library to read the given configuration filephp ssh2 函数 resolve the realpath of a provided path stringphp tidy 函数 returns the number of tidy configuration errors encountered for specified documentphp xmlwriter 函数 create new xmlwriter using memory for string outputphp mongogridfsfile returns this file s contents as a string of bytesphp 安装/配置 plugin configuration file =1.1.x php normalizer checks if the provided string is already in the specified normalization formphp normalizer normalizes the input provided and returns the normalized stringphp phardata set the contents of a file within the tar/zip to those of an external file or stringphp sdo das xml 函数 creates an xml document object from scratch without the need to load a document from a file or stringphp splfileinfo returns the path to the file as a stringphp swfshape draws the first character in the given string into the shape using the glyph definition from the given fontphp tidy get current tidy configurationphp tidy returns the value of the specified configuration option for the tidy documentphp tidy repair a file and return it as a stringphp tidy repair a string using an optionally provided configuration filephp ziparchive add a file to a zip archive using its contents
关注编程学问公众号