php专区

 首页 > php专区 > PHP基础 > 函数 > 这个可是好东西,以后大家可能会用上哦:HTMLtoXHTMLConverter

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

分享到:
【字体:
导读:
         摘要:?if(!empty($type)){if($typepath){if(!empty($path)){if(file_exists($path)is_file($path)){$filefile($path);if(substr($file[0],0,9)!!DOCTYPE)$doctype0;$filejoin(,$...

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

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) != "                     $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) != " //$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:









}
?>
原文自www.evilwalrus.com 这个可是好东西,以后大家可能会用上哦:HTMLtoXHTMLConverter
分享到:
区域
区域 如果你想做个颜色列表是否在头痛那么多颜色如何才能列完? 如果你需要让用户选择颜色,但又怕没考虑到颜色代码怎么办? 用rgb(255,255,255)还是用#FFFFFF还是用0x666666好呢? 今天我也碰到了这个问题,顺便就想了个方法,既然想出来了那大家就来共享一下~, Code: ________...
再来个快的
再来个快的   应用例,给文字加上拼音 再来个快的
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……