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;

}

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.'"...>';.

You have not put quotes around the HTML attribute.

Change the line to:

$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."'>";

When you omit the quotes like this, the second class name will be treated as another property.

Problems like this can be easily avoided if you validate your markup ;-)

You can escape spaces using \x20 and \040 in php.

http://php.net/manual/en/regexp.reference.escape.php

Please see the manual