-6
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();
4

2 回答 2

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;
}
于 2013-03-28T21:08:12.707 回答
-1

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

那么案例的使用必须是这样的:

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

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

于 2013-03-28T21:10:20.707 回答