<!DOCTYPE html>
<html>
<head>
<title>A loop of your own</title>
<link type='text/css' rel='stylesheet' href='style.css'/>
</head>
<body>
<?php
//Add while loop below
$hello = true;
while($hello = true):
{
echo "Loop is runnin";
for($i = 0; $i <= 3; $i++)
{
$hello = false;
}
}
endwhile
?>
</body>
</html>
我的錯誤是:無限循環。在while循環中的語句不起作用?
我該如何解決這個問題?我練;-)
我想了一會兒循環中循環,代碼必須說3次「循環運行」,然後讓
變量$你好假。
$hello = true;
while($hello == true):
echo "Loop is runnin";
for($i = 0; $i < 3; $i++)
{
$hello = false;
}
endwhile;
這是結果,但如果你們有你會看到它銳利的眼睛,for循環WIL只運行一次:P因爲它會嘗試設置$招呼3倍時間爲false。
但還是非常感謝大家的回答我的問題;)
1.'while'語句之後做了什麼? 2. $ hello == true是邏輯表達式,$ hello = true是賦值。你需要第一個。 – sashkello
@sashkello它開始一個*選擇,而語法*。 – deceze
@deceze在這種情況下,那些花括號是幹什麼的? ;) – PeeHaa