创建星金字塔

时间:2015-04-13 17:46:47

标签: php web

//I want to create a star pyramid..but it not work..can someone assist me to solve it..

这是代码

<?php

for ($x=1;$x<=5;$x++)
{
    echo "<center>";
    for ($y=1;$y=$x;$y++)
    {
        echo "*";
    }
    echo "<br>";
}
?>

这是输出


致命错误:第6行的C:\ xampp \ htdocs \ StarPyramid2.php超出了30秒的最长执行时间

1 个答案:

答案 0 :(得分:0)

我愿意:

$stars = "*";
echo "<center>";
for ($x=1;$x<=5;$x++)
{
    echo $stars;
    echo "<br>";
    $stars .= "*";
}
echo "</center>";