2017-06-02 27 views
-1

PHP動態按鈕值,這是我的問題:從陣列

echo '<form class="dugme" method="post" name="$b" value=""> 
<button type="submit">Pusti</button> 
</form>'; 

我已經定義$ B可變,並希望與for循環($ B繪製此頁面上= 0; $ B < = 10; $ b ++)。但是在每一個使用「」,「'的場景......我得到的名稱=」$ b「;

我的代碼:

for ($b=0; $b <= 10; $b++){ 
echo '<form class="dugme" method="post" name="$b" value=""> 
<button type="submit">Pusti</button></form>'; 
} 

回答

1

您需要連接正確

for ($b=0; $b <= 10; $b++){ 
echo '<form class="dugme" method="post" name="'.$b.'" value="'.$b.'"> 
<button type="submit">Pusti</button></form>'; 
} 

注:單引號裏面的東西考慮的字符串。你需要逃避它,或者你需要像這樣連接