PHP案例错误

时间:2013-03-28 21:00:52

标签: case php

Line 9: Parse error: syntax error, unexpected T_CASE:
line:"case "reinstall"

代码:

 if ( check_permissions( "hardware_info", "" ) )
    {
        $link_hardware_info = link_to( $label = $singlerow_hardware['display'], $path = "hardware/info/{$singlerow_setup['hardware_id']}" );
        $col2_array[] = li_links( "{$img_arrow_up} {$link_hardware_info}" );
    }
    break;
case "reinstall" :
    do
    {
        $module_page_title = translate_text( "tpl_store_reinstall" );
        $singlerow_install = query_singlerow( $table = "store_installs", "`id` = '{$load_module_id}'" );
        $singlefield_hardware_id = query_singlefield( $table = "store_setups", "hardware_id", "`id` = '{$singlerow_install['setup_id']}'" );
        $label_display_store = query_singlefield( $table = "store_produts", "display", "`id` = '{$singlerow_install['product_id']}'" );
        $link_information_up = link_to( $label = $label_display_produtct, $link = "installs/info/{$load_module_id}" );
        $col2_array[] = li_links( "{$img_arrow_up} {$link_information_up}" );
        $dbform_array['file_id'] = $singlerow_install['file_id'];
        $html_main .= form_default( $path = "installs/reinstall/{$load_module_id}" );
        $html_main .= form_fieldset( );
        $html_main .= form_legend( $legend = translate_text( "tpl_auto_install" )." ".translate_text( "tpl_package" ) );
        if ( !empty( $postdata_valid['file_id'] ) )
        {
            $setup_type = query_singlefield( $table = "store_files", "setup", "`id` = '{$postdata_valid['file_id']}'" );
            if ( $setup_type == "archive" )
            {
                $link_store_reinstall_id = squeezebox( $label = translate_text( "tpl_store_reinstall", "lower" ), $link = "connect/reinstall/{$load_module_id}/?reinstall_file_id={$postdata_valid['file_id']}" );
            }

我已经尝试了另一种解决方案,但没有奏效,

case "reinstall":do_function_reinstall();do_function_reinstall();  break;function do_function_reinstall();

2 个答案:

答案 0 :(得分:1)

case关键字只能出现在switch块中。确保您的代码与此类似:

switch($variable) {
    case "foo":
        // code to handle when $variable == "foo"
    break;
    case "reinstall":
       do
       {
           // loop content
       } while (condition); // make sure there is a semicolon here.
    break;
}

答案 1 :(得分:-1)

您的代码不够清晰!因为CASE语句是在使用switch语句后使用的,但是因为我看到你的代码中没有switch语句,所以我不知道这是不是一个类型

然后案件的使用必须如下:

switch(VARIABLE_NAME)
    {
        case "reinstall":{//Here put your instructions}
    }

试试这个并告诉我结果:)