我非常想知道实际上是否是一个函数 swicht,我可以解决接收参数变量的情况。在这里,我显示代码。
<?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并向我显示错误:解析错误:语法错误、意外的"for"(T_FOR)、C:''xampp''htdocs 中的预期大小写 (T_CASE) 或默认值 (T_DEFAULT) 或"}"
谢谢。我也对编程充满热情,他们很乐意贡献什么。问候。
看起来你在问你是否可以使用 for
循环来生成 switch
语句中的案例。不,你不能;switch
语句只能包含case
节和default
节。
有关更多详细信息,请参阅 switch
上的 PHP 文档。