note 74555 added to ref.tidy
| From: | GustsKaksis at osu1 dot php dot net | Date: | Tue, 17 Apr 2007 12:09:59 +0000 |
| Subject: | note 74555 added to ref.tidy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125517@lists.php.net to get a copy of this message | ||
This is an example of how-to prepare correct HTML for browsers that do not understand this fancy
thing.
Input: XHTML
Output: HTML (IE6, IE7), XHTML (others)
<?php
class XHTMLOut {
public $type = 'application/xhtml+xml';
public function __construct(){
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')>0){;
$this->type = 'text/html';
header ('Content-type: '.$this->type);
ob_start();
} else {
header ('Content-type: '.$this->type);
echo '<?xml version="1.0"
encoding="utf-8"?>'."\n";
}
}
public function __destruct(){
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')>0){
$str = ob_get_clean();
if (trim($str) != ''){
$config = array(
'doctype' => 'strict',
'indent' => true,
'input-xml' => false,
'output-xml' => false,
'wrap' => 0,
'output-html' => true);
$tidy = new tidy();
$tidy->parseString($str, $config, 'utf8');
$tidy->cleanRepair();
echo $tidy;
}
}
}
}
$out = new XHTMLOut();
?>
<!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"
xml:lang="en" lang="en">
<head>
<title>Firefox, Opera, Safari XHTML; IE6, IE7 HTML</title>
<meta http-equiv="Content-Type" content="<?php echo $out->type; ?>;
charset=utf-8" />
<meta http-equiv="content-language" content="en" />
</head>
<body>
<h1>Sample Title</h1>
<p>Sample Paragraph</p>
<p><img src="image.jpg" alt="image" title="sample"
/></p>
</body>
</html>
----
Server IP: 159.148.13.2
Probable Submitter: 159.148.13.35
----
Manual Page -- http://www.php.net/manual/en/ref.tidy.php
Edit -- https://master.php.net/note/edit/74555
Del: integrated -- https://master.php.net/note/delete/74555/integrated
Del: useless -- https://master.php.net/note/delete/74555/useless
Del: bad code -- https://master.php.net/note/delete/74555/bad+code
Del: spam -- https://master.php.net/note/delete/74555/spam
Del: non-english -- https://master.php.net/note/delete/74555/non-english
Del: in docs -- https://master.php.net/note/delete/74555/in+docs
Del: other reasons-- https://master.php.net/note/delete/74555
Reject -- https://master.php.net/note/reject/74555
Search -- https://master.php.net/manage/user-notes.php