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.
tidy::repairString
tidy_repair_string
(PHP 5, PECL tidy >= 0.7.0)
tidy::repairString -- tidy_repair_string — تعمیر رشته با استفاده شده از فایل تنظیمات فراهم شده اختیاری
Description
شیوه شیگرا
شیوه روالگرا
تعمیر رشته داده شده.
Parameters
- data
-
داده برای تعمیر شدن.
- config
-
config میتواند به عنوان آرایه یا به عنوان رشته ارسال شود به عنوان نام فایل تنظیمات تفسیر شده در غیر این صورت خود گزینهها در نظر گرفته میشود.
بررسی » http://tidy.sourceforge.net/docs/quickref.html برای توضیح هر گزینه.
- encoding
-
پارامتر encoding کدگذاری برای سند ورودی/خروجی را تعیین میکند . مقادیر ممکن برای کدگذاری موارد زیر هستند: ascii، latin0، latin1، raw، utf8، iso2022، mac، win1252، ibm858، utf16، utf16le، utf16be، big5، و shiftjis.
Return Values
بازگرداندن رشته تعمیر شده.
Examples
Example #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;
?>
The above example will output:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>test</title> </head> <body> <p>error</p> </body> </html>
Notes
Note: The optional parameters config and encoding were added in Tidy 2.0.
See Also
- tidy::parseFile() - تحلیل markup در فایل یا URI
- tidy::parseString() - تحلیل سند ذخیره شده در رشته
- tidy::repairFile() - تعمیر فایل و بازگرداندن آن به عنوان رشته
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
));
?>
