PHP-输出添加了&书信电报;br/>&引用;。。。群尸玩过界
所以我的头撞到了这个。。。我对PHP还不是很有经验,有人让我编辑一个WP插件 PHPPHP-输出添加了&书信电报;br/>&引用;。。。群尸玩过界,php,line,line-breaks,Php,Line,Line Breaks,所以我的头撞到了这个。。。我对PHP还不是很有经验,有人让我编辑一个WP插件 PHP foreach ($options['forms'][$form_id]['inputs'] as $id => $input) { if (!$input['show']) continue; $val = ''; if (isset($_POST[$id])){ $val = esc_attr(
foreach ($options['forms'][$form_id]['inputs'] as $id => $input) {
if (!$input['show'])
continue;
$val = '';
if (isset($_POST[$id])){
$val = esc_attr(strip_tags(stripslashes($_POST[$id])));
}else{
if( isset($input['value']) ) $val = esc_attr(strip_tags(stripslashes($input['value'])));
}
$error = ' ';
if (isset($input['error']) && $input['error'])
$error = ' error ';
if($input['type'] != 'hidden')
$content .= "\t".'<div class="sf_input_container_byben"><label class="w2llabel'.$error.$input['type'].'" for="sf_'.$id.'">'.esc_html(stripslashes($input['label'])).':';
if ($input['required'] && $input['type'] != 'hidden')
$content .= ' *';
if($input['type'] != 'hidden')
$content .= '</label>';
if ($input['type'] == 'text') {
$content .= '<input value="'.$val.'" id="sf_'.$id.'" class="w2linput text" name="'.$id.'" type="text"/></div>';
} else if ($input['type'] == 'textarea') {
$content .= '<textarea id="sf_'.$id.'" class="w2linput textarea" name="'.$id.'">'.$val.'</textarea></div>';
} else if ($input['type'] == 'hidden') {
$content .= '<input type="hidden" id="sf_'.$id.'" class="w2linput hidden" name="'.$id.'" value="'.$val.'"></div>';
}
}
foreach($options['forms'][$form\u id]['inputs']as$id=>$input){
如果(!$input['show'])
继续;
$val='';
如果(isset($\u POST[$id])){
$val=esc_attr(strip_标记(stripslashes($_POST[$id]));
}否则{
if(isset($input['value'])$val=esc_attr(strip_标记($input['value']));
}
$error='';
如果(isset($input['error'])&&$input['error'])
$error='error';
如果($input['type']!='hidden')
$content.=“\t”。.esc_html(条带斜杠($input['label'])。:”;
如果($input['required']&&$input['type']!='HIDDED')
$content.='*';
如果($input['type']!='hidden')
$content.='';
如果($input['type']='text'){
$content.='';
}else if($input['type']=='textarea'){
$content.=''.$val.';
}else if($input['type']=='hidden'){
$content.='';
}
}
显然这是片面的
除了在每个
(结束标记)之后我都会得到一个
之外,所有内容都按预期输出。nl2br未在php文件中的任何位置使用
我错过了什么?如果需要更多信息,我可以直接链接到这些文件
HTML输出为:
<div class="sf_input_container_byben">
<label class="w2llabel text" for="sf_first_name">First name: *</label><br />
<input value="" id="sf_first_name" class="w2linput text" name="first_name" type="text"/>
</div>
名字:*
通常,您可以通过以下操作在CSS中修复此问题:
label{display: inline;}
似乎标签的作用类似于块元素,因此将其更改为内联,甚至内联块,它应该停止在末尾添加额外的行。请注意,您可能已经有了导致标签显示为块的代码,因此请首先在css文件中搜索它。不是最佳修复方案,但我的时间不够了,所以我只使用了
显示:无在我的CSS中使用code>隐藏表单中的
元素
向Paul道具,感谢他将我链接到一个论坛线程,该论坛线程涵盖了一个单独的问题,但提供了解决方案。发布class=“w2label”
p.S的CSS代码。看起来你没有在
中消毒$input['type']
。也可能是$id
。CSS中没有任何class=“w2label>的内容“
这可能会导致问题。它将显示设置为表格单元格,设置宽度,并添加填充。有人告诉我,esc_html()
是罪魁祸首。您可以演示此函数的功能吗?您的页面输出看起来像是有换行符(
),还是实际上有换行符?例如,
s是显示块。发布HTML源代码可能吗?我提到的是CSS,不是PHP。如果有标签为{display:block;}的CSS,这就是修复方法。与PHP无关。