Php 确认通知:“;表中所示的起始标签DIV;

Php 确认通知:“;表中所示的起始标签DIV;,php,html,validation,Php,Html,Validation,我在运行验证时遇到此错误:“在表中看到Start tag div”,结果是“在上次错误后无法恢复。任何进一步的错误都将被忽略” 为什么你不在你的桌子里使用tr和td? 表标记内的div标记不正确。div标记可能不是表的直接子级,但可能在td标记内使用。错误消息“表内的div标记”误导了我。它可能是“内在的”,只是不是一个直接的孩子 <!DOCTYPE html> <html> <head> <title>Test</title>

我在运行验证时遇到此错误:“在表中看到Start tag div”,结果是“在上次错误后无法恢复。任何进一步的错误都将被忽略”



为什么你不在你的桌子里使用tr和td?
表标记内的div标记不正确。

div标记可能不是表的直接子级,但可能在td标记内使用。错误消息“表内的div标记”误导了我。它可能是“内在的”,只是不是一个直接的孩子

<!DOCTYPE html>
<html>
<head>
  <title>Test</title>
</head>
<body>

<table>
   <div>DIV is not allowed here</div>
   <caption>  This it the Caption
          <div>This is a caption div -- why?</div>
   </caption>
     <tr>  <!-- tr Row 1 may not contain text.  -->
       <td> Col 1 Stuff goes here.</td>
       <td> Col 2 here.</td>
     </tr>
     <tr>
       <td>Col 1 of Row 2 is here.</td>
       <td>Col 2 Row 2
          <div>Sub part A</div>
          <div>Sub part B</div>
          <div>Sub part C</div>
       </td>
     </tr>
</body>
</html>

试验
这里不允许使用DIV
这是标题
这是一个标题部分——为什么?
第一列的东西在这里。
这里是Col 2。
第2排的第1列在这里。
第2列第2排
A分编
B分部
C分编
给出了错误- 错误:在表中看到开始标记div。 来自第8行第8列;至第9行第8列

↩↩↩ DIV是

致命错误:上次错误后无法恢复。任何进一步的错误都将被忽略

<div class="post">
    <table>

        <?php
        $dir   = 'img/';
        $filetype = '*.*';
        $allow = array('jpg');
        $files = glob($dir.$filetype);
        $newest_images_first = true;
        $files = array_reverse($files);
        $i=0;
        $open = opendir($dir);      
        while (($file=readdir($open))!==false) {$ext=str_replace('.', '', strrchr($file, '.'));if (in_array($ext, $allow)) $list[$i++]=$file; }
        $perPage= 20;
        $total=count($list);
        $pages=ceil($total/$perPage);
        $thisPage=isset($_GET['pg'])?$_GET['pg']-1:0;
        $start=$thisPage*$perPage;
        $pageNumber= $thisPage+1;
        $perRow= 1;
        $imgCnt=0;
        $imgCnt+=1;
        for ($i=$start;$i<$start+$perPage;$i++) 

        { // <---------- this opens element

            echo '<div class="item">';  // <----------- this div doesn't open!!

                // Preloader
                echo '<div class="preloader"></div>';

                if (isset($list[$i])) {

                  echo '<figure>';
                   echo '<div class="photo">';

                    $exif = exif_read_data($files[$i], 0, true);
                    error_reporting(E_ERROR | E_PARSE);
                    $title = substr($files[$i],strlen($dir),strrpos($files[$i], '.')-strlen($dir));
                    $title = str_replace( array( '%', '_'), " ", $title);
                    $title = substr($title, 5);
                    $title = str_replace( array('', '_'), "", $title);
                    $imgname = $files[$i]; 
                    echo '<img src="'.$imgname.'" alt="blahblah '.$title.'" onLoad="this.width*=0.6;imgLoaded(this);" onError="this.onerror=null;this.src="bundles/blank.svg";">';

                  echo '</div>'; // .photo

                  echo '<figcaption>';                  

                  $title = preg_replace('/\'([^\']+)\'/', '<em>$1</em>', $title);
                  echo '<h2>'."". $title .'</h2>';
                  echo "<p>".$exif['IFD0']['ImageDescription']."</p>";

                  echo '</figcaption>';     
                 echo '</figure>';          

                            }

                            else {
                            echo "<td></td>";
                            }

                    if ($imgCnt%$perRow==0) echo "</tr><tr>";

                    echo '</div>'; // .item

                    }

                    closedir($open);
                    ?>

                    </table>        

                </div> <!-- post -->
当删除带有注释的第8行时,错误消失。 第13行演示了另一个类似的错误- tr不能直接包含文本。 现在给出了验证错误- 错误:在表中错误放置了非空格字符。
同样的措辞,imho,误导性的

元素唯一有效的直接后代。这能解决问题吗?如果是这样,你应该举个例子。