我只想在PHP中使用for循环打印金字塔,就像给图像一样

My code is

<center>
<?php

    for($i = 0; $i < 7 ; $i++) {

        for($j = 0; $j < $i; $j++) {
            echo "*";
        }
        echo "<br/>";
    }
?>
<center>

But I want is pyramid with useing <center></center> html tags.

You're looking for something like this:

<div class="text-center"><!-- or however you choose to center this -->
<?php
$w = 7;
for ($n = 0; $n < $w; $n++) {
    echo str_repeat("-", $n) . "<br>";
}
?>
</div>
<?php
   int k =0;
   for($i=1;$i<=20;$i++){
      for(a=1;a<=20;$a++){
         echo "  ";
      }   
      while(k!=(2*i-1){
         echo "* ";
         k++;
      }
      k=0;
      echo "
";

   }
?>