dongyuan7110 2012-12-20 10:48
浏览 39
已采纳

php修剪空间后的一切

I'm really scratching my head...

I'm trying to add a class to my input and textarea fields, but whenever I do it like this:

$inputclass = $class." multilanginput"; 

the second part is not appended, but when I leave out the space and do it like this:

$inputclass = $class."multilanginput"; 

it works just fine...

i've never had this issue before, any ideas what's going wrong?

it's part of this little function:

function backend_dynamic_dialoginput($label,$class,$type = 'single',$lang = "none"){


if($lang == "none"){
    $lang = "";
}
else{
    $lang = "_".$lang;
}

$class = $class.$lang;
$id = "";

if($type == "singleint" || $type == "multiint"){
    $id = $class."_m";
    $inputclass = $class." multilanginput";
}else{
    $inputclass = $class;  
}


$html = "
<div style='padding-left:10px;margin-top:1px;background-color:#dddddd;padding-bottom:8px;padding-top:8px;'>
    <div style='float:left;font-size:13px;color:#5a5a5a;padding-top:6px;margin-bottom:2px;width:30%;text-align:right;padding-right:4px;' class='font_lato'>".$label."</div>
    ";

    if($type == "single" || $type == "singleint"){
        $html .= "<input type='text' value=".$inputclass." style='font-size:12px;width:60%;border:1px solid #ffffff;padding:2px;background-color:#dddddd;' class='font_din' id='".$id."' class='".$inputclass."'>";
    }
    else if($type == "multi" || $type == "multiint"){
        $html .= "<textarea style='font-size:12px;width:60%;border:1px solid #ffffff;padding:2px;background-color:#dddddd;' class='font_din' id='".$id."' class='".$inputclass."' rows=2></textarea>";
    }

    $html .= "
    ";

    if($type == "singleint" || $type == "multiint"){
    $html .= "<div style='float:right;font-size:12px;background-color:#eeeeee;margin-right:4px;' id='".$class."' class='togglefullscr font_lato'>Int.</div>";
    }


    $html .= "
    </div>";

if($type == "singleint" || $type == "multiint"){
$html .= backend_dynamic_internationaldialog($label,$class,$type);   
}

return $html;

}

  • 写回答

3条回答 默认 最新

  • doukuanjing5404 2012-12-20 10:51
    关注

    Your quotation marks are wrong:

    $html .= "<input type='text' value=".$inputclass."

    It has to be $html .= "<input type='text' value='".$inputclass."' or $html .= "<input type='text' value=\"".$inputclass."\".

    However, I strongly recommend using single quotes for strings:

    $html .= '<input type="text" value="'.$inputclass.'"...>';.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大