2013-10-23 27 views
-2

我有一個偉大的願望,知道是否實際上是一個函數swicht,我可以解決一個接收參數變量的情況。 這裏我顯示代碼。如何在php中使用開關大小寫變量?

<?php 
function devento($diaa,$mess,$ayoo) 
{ 
    $sieven=false; 
    $evento="$diaa-$mess-$ayoo"; 
    //echo $evento; 
switch ($evento) 
{ 
     for($a=10;$a<=15;$a++) 
      { 
       for($i=1;$i<=12;$i++) 
       { 
        for($j=1;$j<=31;$j++) 
        { 
         //echo " $j $i 20$a <br>"; this if it works with the for 

         case $j."-".$i."-20".$a://question? 
         //or 
         case "$j-$i-20$a$ ": //question? 
         //case '1-1-2013': //this if it works without the for 

        } 
       } 
      } 

      $sieven=true; 
         break; 


      // case $i.'-'.$j.'-'.$a:  
} 

return $sieven; 
} 

如果它工作正常,我試了它在一個單獨的PHP。 PHP和顯示我的錯誤: 解析錯誤:語法錯誤,意外 '爲'(T_FOR),在C期待的情況下(T_CASE)或默認(T_DEFAULT)或 '}':\ XAMPP \ htdocs中

謝謝非常。 我也熱衷於編程,他們可以很高興地做出貢獻。 問候。

+0

你想完成什麼? – Ryan

+0

你知道交換機是做什麼的嗎?您可能想看看PHP手冊。 http://php.net/manual/en/control-structures.switch.php –

+1

看來你正在嘗試做一個映射。這不是做這件事的方法。 – bksi

回答

2

它看起來像是在問您是否可以使用for循環來生成switch語句中的個案。你不能; switch聲明只能包含casedefault部分。

查看the PHP documentation on switch瞭解更多詳情。

相關問題