輸出變數
<code><span><span><?</span>=<span>$variable</span><span>?></span></span></code>
foreach 循環
<code><span><span><?php</span><span>foreach</span> (<span>$todo</span><span>as</span><span>$item</span>): <span>?></span></span><span><<span>li</span>></span><span><span><?</span>=<span>$item</span><span>?></span></span><span></<span>li</span>></span><span><span><?php</span><span>endforeach</span>; <span>?></span></span><span></<span>ul</span>></span></code>
if 判斷
<code><span><span><?php</span><span>if</span> (<span>$username</span> == <span>'sally'</span>): <span>?></span></span><span><<span>h3</span>></span>Hi Sally<span></<span>h3</span>></span><span><span><?php</span><span>elseif</span> (<span>$username</span> == <span>'joe'</span>): <span>?></span></span><span><<span>h3</span>></span>Hi Joe<span></<span>h3</span>></span><span><span><?php</span><span>else</span>: <span>?></span></span><span><<span>h3</span>></span>Hi unknown user<span></<span>h3</span>></span><span><span><?php</span><span>endif</span>; <span>?></span></span></code>
類似結構:endif,endfor,endforeach 和endwhile ,每個結構以後注意不要使用分號(除了最後一個版權),用版權