Wordpress 未定义索引错误消息
可能重复:Wordpress 未定义索引错误消息,wordpress,php,Wordpress,Php,可能重复: 我对PHP还不熟悉,并经常使用它。我的php文件中有以下代码 $output = "<div style='display:none'> <div class='contact-top'></div> <div class='contact-content'> <h1 class='contact-title' style='text-align:center'>Write a Testim
我对PHP还不熟悉,并经常使用它。我的php文件中有以下代码
$output = "<div style='display:none'>
<div class='contact-top'></div>
<div class='contact-content'>
<h1 class='contact-title' style='text-align:center'>Write a Testimonial:</h1>
<div class='contact-loading' style='display:none'></div>
<div class='contact-message' style='display:none'></div>
<form action='#' style='display:none'>
<label for='contact-name'>*Name:</label>
<input type='text' id='contact-name' class='contact-input' name='name' tabindex='1001' />
<label for='contact-email'>*Email:</label>
<input type='text' id='contact-email' class='contact-input' name='email' tabindex='1002' />";
if ($extra["form_subject"]) {
$output .= "
<label for='contact-subject'>Subject:</label>
<input type='text' id='contact-subject' class='contact-input' name='subject' value='' tabindex='1003' />";
}
$output .= "
<label for='contact-message'>*Message:</label>
<textarea id='contact-message' class='contact-input' name='message' cols='40' rows='4' tabindex='1004'></textarea>
<br/>";
if ($extra["form_cc"]) {
$output .= "
<label> </label>
<input type='checkbox' id='contact-cc' name='cc' value='1' tabindex='1005' /> <span class='contact-cc'>Send me a copy</span>
<br/>";
}
$output .= "
<label> </label>
<button type='submit' class='contact-send contact-button' tabindex='1006'>Send</button>
<button type='submit' class='contact-cancel contact-button simplemodal-close' tabindex='1007'>Cancel</button>
<br/>
<input type='hidden' name='token' value='" . smcf_token($to) . "'/>
</form>
</div>
</div>";
echo $output;
$output=”
写一篇推荐信:
*姓名:
*电邮:
";
如果($extra[“表格主题”]){
$output.=”
主题:
";
}
$output.=”
*信息:
“;
如果($extra[“form_cc”]){
$output.=”
给我寄一份
“;
}
$output.=”
发送
取消
";
echo$输出;
当我试图运行代码时,虽然出现了模型框,但它也显示了一个php错误
下面是我收到的错误消息
注意:未定义索引:第56行F:\wamp\www\blog\wordpress\wp content\plugins\demo\contact.php中的表单\u cc
知道出了什么问题吗?很简单,似乎数组中没有此索引的定义,在这种情况下,似乎没有得到输入值很简单,似乎数组中没有此索引的定义,在这种情况下,您似乎没有得到输入的值,因为数组
extra
没有名为form\u cc
的索引。对数组extra
执行var_转储,以便查看问题所在。还可以使用isset()
和empty()
方法。因为数组extra
没有名为form\u cc
的索引。对数组extra
执行var_转储,以便查看问题所在。还可以使用isset()
和empty()
方法。在这种情况下,只需使用:
if (!empty($extra["form_cc"])) {
...
}
empty()将检查数组中是否存在键/索引,以及是否设置了值。在这种情况下,只需使用:
if (!empty($extra["form_cc"])) {
...
}
empty()将检查数组中是否存在键/索引,以及是否设置了值。问题是在
$extra
数组中没有名为“form_cc”的位置(索引)。因此,您应该使用
if (! empty($extra["form_cc"]))
{
// do stuff
}
问题是在
$extra
数组中没有名为“form_cc”的位置(索引)。因此,您应该使用
if (! empty($extra["form_cc"]))
{
// do stuff
}
将删除警告消息,这是检查isset()的一个好习惯
将删除警告消息,这是检查isset()的一个好习惯