将 php 变量添加到从之前转换为 php 的 html/javascript 语句中


Add a php variable to an html/javascript statement that is converted to php from before

这是一个包含一些html/javascript代码的php变量。这是从以前转换为 php,但我需要添加一个 php 变量。我有一个 php 变量是 $user->user_email .如何在此处添加此变量:{this.value ='''';?我的意思是该值向我显示了 php 变量。

$button .= '<input type="text" id="parspalpaiddownloads_email_'.$button_id.'" style="font-family: tahoma, verdana; font-size: 14px; line-height: 14px; margin: 5px 0px; padding: 3px 5px; background: #FFF; border: 1px solid #888; width: 200px; -webkit-border-radius: 3px; border-radius: 3px; color: #666; min-height:28px" value="'.esc_attr(__('Email', 'parspalpaiddownloads')).'" onfocus="if (this.value == '''.esc_attr(__('Email', 'parspalpaiddownloads')).'''){this.value =''''; this.style.textAlign= ''left''; this.style.direction= ''ltr'' }" onblur="if (this.value == '''') {this.value = '''.esc_attr(__('Email', 'parspalpaiddownloads')).''';  this.style.textAlign= ''right''; this.style.direction= ''rtl''}" /></div>';

你正在用''筛选单引号,但实际上你必须打破字符串并注入你的变量。你的答案是

this.value ='''.$user->user_email.''';

点(.)将弦部分连接成一个。