未定义的变量:PHP中的主体

ijxebb2r  于 2022-12-10  发布在  PHP
关注(0)|答案(2)|浏览(134)

在过去的几年里,我一直在自学我们的办公室网站,最近,我们最初的网络人员无法在她建立的网站上工作或提供帮助。我们的几个网站有错误日志,这些日志被未定义的变量通知填满。根据我的研究,我认为我需要声明它给出的错误。下面的例子来自一个引用body的站点。我是一个php新手,所以我感谢任何帮助。如果我添加$body =($_POST['body']));我害怕被那些可能不必要的改变冲昏头脑,因为她不能修复我可能犯的任何错误。
PHP注意:未定义的变量:第48行email.php中的正文

<?php
        $emailTo = "email@email.com"; // Email address you want submitted forms to go to
        $Subject = "Email Inquiry"; // subject line for emails
        $name = Trim(stripslashes($_POST['name']));
        $phone = Trim(stripslashes($_POST['phone']));
        $email = Trim(stripslashes($_POST['email']));
        $mailheader = "From: $email \r\n";
        $message = Trim(stripslashes($_POST['message']));
        $human = Trim(stripslashes($_POST['human']));


        // prepare email body text
        $Body .= "Name: ";                                          (this is line 48)
        $Body .= $name;
        $Body .= "\n";
        $Body .= "Phone: ";
        $Body .= $phone;
        $Body .= "\n";
        $Body .= "Email: ";
        $Body .= $email;
        $Body .= "\n";
        $Body .= "Message: ";
        $Body .= $message;
        $Body .= "\n";
1zmg4dgp

1zmg4dgp1#

这种情况下..需要在执行字符串连接之前定义变量$Body。

// prepare email body text
    $Body = ''; // define first
    $Body .= "Name: ";
    $Body .= $name;
    $Body .= "\n";
    $Body .= "Phone: ";
    $Body .= $phone;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $message;
    $Body .= "\n";
gpfsuwkq

gpfsuwkq2#

(!)注意:未定义的变量:删除第88行调用堆栈中C:\wamp 64\www\website\assets\pg\admins\edit_product.PHP中的产品图像

相关问题