English 中文(简体)
十三. 隔开声明行为
原标题:Strange switch-statement behavior

Can someone show me why this switch statement doesn t output the same as the if statement? And more important, how do I get them to output the same?

<>Switch

switch ($list_day) { 
        case $today : 
            $calender .=  <td class="today"> ;
        default : 
            $calender .=  <td> ;
    }

<>If

if ($list_day == $today) {
        $calendar.=  <td class="today"> ;
    } else {
        $calendar.=  <td> ;
    }
最佳回答

你有了一个打字:

switch ($list_day) { 
    case $today : 
        $calendar .=  <td class="today"> ;
        break;
    default : 
        $calendar .=  <td> ;
}

除先前提交的假件外,你还打上了笔记本,而不是加薪。

问题回答

页: 1

switch ($list_day) { 
        case $today : 
            $calender .=  <td class="today"> ;
            break;
        default : 
            $calender .=  <td> ;
    }

如果你没有打破开关声明的执行,就在下一个标签上继续。 这使你能够把标签加在一起:

switch($number) {
case 1: case 2: case 3:
  echo  1 - 3 ;
  break;
case 4:
  echo  4 ;
  break;
default
  echo  any other number ;
}

页: 1

在帕斯卡尔文体法中,如帕斯卡尔,视像基础,你不需要科索沃广播公司处理每一案件。 但在C-Style/Java/PHP/etc,需要:

switch ($list_day) { 
    case $today : 
        $calender .=  <td class="today"> ;
        break;
    default : 
        $calender .=  <td> ;
}

这可以用来做一些小事,让你 figure!





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签