php alternative syntax

WBOY
Release: 2016-07-30 13:29:51
Original
1256 people have browsed it

Output variables

<code><span><span><?</span>=<span>$variable</span><span>?></span></span></code>
Copy after login

foreach loop

<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>
Copy after login

if judgment

<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>
Copy after login

Similar structures: endif, endfor, endforeach and endwhile, be careful not to use semicolons after each structure (except the last one), use colons

Copyright Statement: Knowledge comes from the people and is used by the people! Reprinting is welcome. Please attach a link to this article at the beginning. The article will be updated from time to time!

The above introduces the PHP alternative syntax, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
gt lt
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template