Hello, such a problem: you need to insert in the PHP loop a line drawing from Html, but something is missing. Tell me how to implement it correctly?

<? for ($i = 1; $i <= 5; $i++) { echo $i; <polyline points="<? echo $x ?>,<? echo $y+$h ?> <? echo $x*$l ?>,<? echo $y+$h ?> <? echo $x*$l+$dx ?>, <? echo $y+$dy+$h ?> <? echo $x*$l ?>, <? echo $y+2*$dy+$h ?> <? echo $x ?>, <? echo $y+2*$dy+$h ?> <? echo $x-$dx ?>, <? echo $y+$dy+$h ?> " id="silfon" fill=gray stroke="#4D5656" stroke-width="1" > <animateTransform begin="startButton.click" attributeType="XML" attributeName="transform" type="scale" from="1 1" to="1 2" dur="2s" fill="freeze"> </polyline> } ?> 

I need him to draw 5 ($ i) of such figures with a set indent ($ h) from the previous ones

  • What is the problem specifically? Any errors? then add them to the question - koks_rs

2 answers 2

Use alternate syntax for control structures .

In your case, you have a syntax error, so it will be more correct:

 <?php for ($i = 1; $i <= 5; $i++): ?> <?php echo $i; ?> <polyline points="<? echo $x ?>,<? echo $y+$h ?> <? echo $x*$l ?>,<? echo $y+$h ?> <? echo $x*$l+$dx ?>, <? echo $y+$dy+$h ?> <? echo $x*$l ?>, <? echo $y+2*$dy+$h ?> <? echo $x ?>, <? echo $y+2*$dy+$h ?> <? echo $x-$dx ?>, <? echo $y+$dy+$h ?> " id="silfon" fill=gray stroke="#4D5656" stroke-width="1" > <animateTransform begin="startButton.click" attributeType="XML" attributeName="transform" type="scale" from="1 1" to="1 2" dur="2s" fill="freeze"> </polyline> <?php endfor; ?> 
  • Thanks, helped - VAShulyak

The script code begins after the opening tag <? and ends closing ?> , left in the comments of the absence of the tag

<? for ($i = 1; $i <= 5; $i++) { echo $i; ?>//нужно закрывающий тэг Для того что бы закончить код сценария PHP <polyline points="<? echo $x ?>,<? echo $y+$h ?> <? echo $x*$l ?>,<? echo $y+$h ?> <? echo $x*$l+$dx ?>, <? echo $y+$dy+$h ?> <? echo $x*$l ?>, <? echo $y+2*$dy+$h ?> <? echo $x ?>, <? echo $y+2*$dy+$h ?> <? echo $x-$dx ?>, <? echo $y+$dy+$h ?> " id="silfon" fill=gray stroke="#4D5656" stroke-width="1" > <animateTransform begin="startButton.click" attributeType="XML" attributeName="transform" type="scale" from="1 1" to="1 2" dur="2s" fill="freeze"> </polyline> <?//а тут нужен открывающий тэг } ?>