Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP开关语句错误_Php_Switch Statement - Fatal编程技术网

PHP开关语句错误

PHP开关语句错误,php,switch-statement,Php,Switch Statement,我创建了一个站点,添加了一个pm,当我转到pm.php时,它会给我一个错误: 致命错误:Switch语句在第673行的/home/vol10_3/HIDDEN.com/HIDDEN/htdocs/includes/classes/pm.class.php中只能包含一个默认子句 代码: 实际上,您并没有像那样使用括号或默认值 <?php switch ($type) { case 'pm': // Do something when $type is 'pm'

我创建了一个站点,添加了一个pm,当我转到pm.php时,它会给我一个错误:

致命错误:Switch语句在第673行的/home/vol10_3/HIDDEN.com/HIDDEN/htdocs/includes/classes/pm.class.php中只能包含一个默认子句

代码:


实际上,您并没有像那样使用括号或默认值

<?php

switch ($type) {
    case 'pm':
        // Do something when $type is 'pm'
        // This can be multiple statements
        break;

    case 'notification':
        // Do something when $type is 'notification'
        // This can be multiple statements
        break;

    default:
       // Do something else
       break;
}

与错误状态相同。如果您还没有阅读手册,请阅读手册。我将投票结束这个问题,因为错误消息完全是不言自明的。
<?php

switch ($type) {
    case 'pm':
        // Do something when $type is 'pm'
        // This can be multiple statements
        break;

    case 'notification':
        // Do something when $type is 'notification'
        // This can be multiple statements
        break;

    default:
       // Do something else
       break;
}