Rumah >pembangunan bahagian belakang >tutorial php >这个可是好东西,以后大家可能会用上哦:HTMLtoXHTMLConverter_PHP

这个可是好东西,以后大家可能会用上哦:HTMLtoXHTMLConverter_PHP

WBOY
WBOYasal
2016-06-01 12:36:161301semak imbas

Xhtml



if (!empty($type)) {
    if ($type == "path") {
        if (!empty($path)) {
            if (file_exists($path) && is_file($path)) {
                $file = file($path);
                if (substr($file[0],0,9) != ") $doctype=0;
                    $file = join(', $file);
                } else {
                    die ("No such file.");
                }
            } else {
                die ("No file specified.");
            }
        } elseif ($type == "file") {
            if (!empty($file)) {

            } else {
                die ("No file specified.");
            }
    } else {
        die ("No file specified.");
    }

# specify html file, check for doctype
//$file = file("file.html");
//if (substr($file[0],0,9) != ") $doctype=1;
//$file = join(', $file);

# make tags and properties lower case, close empty elements, quote all properties
$search  = array ("'(]*>)'e",
                   "'(]*)( />)'ie",
                   "'(]*)(/>)'ie",
                   "'(]*)(>)'ie",
                   "'(\w+=)(\w+)'ie",
                   "'(\w+=)(.+?)'ie");
$replace = array ("'\\1'.strtolower('\\2').'\\3'",
                   "'\\1\\2\\3>'",
                   "'\\1\\2\\3>'",
                   "'\\1\\2\\3 /\\4'",
                   "strtolower('\\1').'\"\\2\"'",
                   "strtolower('\\1').'\\2'");
$file = preg_replace($search, $replace, $file);

# return xhtml-compliant document
echo "";

} else {
?>

HTML -> XHTML Convertor






File path:



OR





File contents:








Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn