search

Home  >  Q&A  >  body text

Why doesn't the color show up?

为什么不显示颜色

<?php


    function test($color1,$color2="red"){

        echo '<table width="800px" border="1px">';

        for($i=1;$i<11;$i ){

            if($i%2==0){

                echo '<tr bgcolor:$color2>';

            }else{

                echo '<tr bgcolor:$color1>';

            }

            for($j=1;$j<11;$j ){

                echo '<td>'.$j.'×'.$i.'='.$i*$j.'</td>';

            }

            echo '</tr>';

        }

        return ;

        echo '</table>';

    }

    $a=test('green');

    echo $a;

?>


DanteDante2109 days ago1664

reply all(2)I'll reply

  • 韦小宝

    韦小宝2019-02-15 09:50:33

    Take a look at the direct output to see if there is any color

    reply
    0
  • Dante

    Thank you, I found out last night that it was a problem with single quotes and double quotes. _(¦3 ∠)_ Single quotes are used outside the two lines of tr bgcolor, so the color is not parsed.

    Dante · 2019-02-15 10:30:29
  • Cancelreply