PHP 中 有类似 for 10 这种语法吗?

WBOY
Release: 2016-06-06 20:08:21
Original
991 people have browsed it

希望大家先看清楚题目哈,

<code>    for 10
    
    next</code>
Copy after login
Copy after login

这是vb语法,就是做10次;

php的话我是会的,下面都能做到上面的过程:

<code>for($i=0;$i</code>
Copy after login
Copy after login
<code>for(;$i</code>
Copy after login
Copy after login
<code>for(;;)
{
    if($i=10)
        break;
    $i++;
}</code>
Copy after login
Copy after login
<code>while($i</code>
Copy after login
Copy after login

但是,都很啰嗦,请问有简单的写法吗?

回复内容:

希望大家先看清楚题目哈,

<code>    for 10
    
    next</code>
Copy after login
Copy after login

这是vb语法,就是做10次;

php的话我是会的,下面都能做到上面的过程:

<code>for($i=0;$i</code>
Copy after login
Copy after login
<code>for(;$i</code>
Copy after login
Copy after login
<code>for(;;)
{
    if($i=10)
        break;
    $i++;
}</code>
Copy after login
Copy after login
<code>while($i</code>
Copy after login
Copy after login

但是,都很啰嗦,请问有简单的写法吗?

<code class="php">$i = 10;
while($i--) {

}</code>
Copy after login

Readable > Simple. A great writer makes readers comfortable.

<code class="php">$a=10;
while ($a-->0){
    //do something
}</code>
Copy after login

楼主,没必要,代码是写给人看的。
for ($i=0;i

这个是最好的了。

没有,你都说了是 语法 ,vb 也没有 $a . $b 这种语法,对不?

Related labels:
php
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