tidy::parseString

tidy_parse_string

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

tidy::parseString -- tidy_parse_stringParse a document stored in a string

说明

面向对象风格

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

过程化风格

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

Parses a document stored in a string.

参数

input

The data to be parsed.

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.

For an explanation about each option, visit » http://tidy.sourceforge.net/docs/quickref.html.

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 a new tidy instance.

范例

Example #1 tidy::parseString() example

<?php
ob_start
();
?>

<html>
  <head>
   <title>test</title>
  </head>
  <body>
   <p>error<br>another line</i>
  </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;
?>

以上例程会输出:

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

参见

相关文章
php domdocument dumps the internal document into a string using html formattingphp bbcode 函数 parse a string following a given rule setphp fdf 函数 read a fdf document from a stringphp fdf 函数 returns the fdf document as a stringphp tidy 函数 returns the number of tidy accessibility warnings encountered for specified documentphp tidy 函数 returns the number of tidy configuration errors encountered for specified documentphp intldateformatter parse string to a field based time valuephp intldateformatter parse string to a timestamp valuephp messageformatter parse input string according to patternphp sdo das xml 函数 creates an xml document object from scratch without the need to load a document from a file or stringphp sdo das xml 函数 returns sdo das xml document for a given xml instance stringphp solrquery returns the maximum number of tokens to parse in each document field that is not stored with termvector supportphp tidy returns a tidynode object starting from the body tag of the tidy parse treephp tidy get the detected html version for the specified documentphp tidy returns the value of the specified configuration option for the tidy documentphp tidy get status of specified documentphp tidy returns a tidynode object starting from the head tag of the tidy parse treephp tidy parse a document stored in a stringphp tidy repair a string using an optionally provided configuration filephp tidy returns a tidynode object representing the root of the tidy parse tree
关注编程学问公众号