1

当我输入:

$site = "http://localhost";

双斜杠后的所有内容都被注释掉。我该如何防止这种情况? 编辑谢谢你的帮助。我想我应该详细说明。我正在设置这个变量,以便我可以在这段代码中使用它:

 if ($numrows == 1){
                          $site = "http://localhost";
                          $webmaster = "myemail@somemail.com"; //not my email
                          $headers = "From: $webmaster";
                          $subject = "Activate Your Account";
                          $message = "Thank you for registering! Click the link below to activate your account.\n";
                          $message .= "$site/activate.php?user=$getuser&code=$code\n";
                          $message .= "You must activate your account to log in.";

                          if(mail($getemail, $subject, $message, $headers)){
                          $errormsg = "You have been registered.  You must activate your account from the activation link sent to <b>$getemail</b>.";
                          $getuser = "";
                          $getemail = "";
                          }else
                          $errormsg = "An error has occurred. Your activation email was not sent.";
                      }else
                       $errormsg = "An error has occurred. Your account was not created.";

我认为问题可能是我的本地主机未设置为发送电子邮件。如果页面实际上在网络上并且我为“$site”变量使用了真实的 URL,这会起作用吗?

4

3 回答 3

0

这应该可以解决问题,但输出会受到影响,因此这不是解决方案:

$site = "http:\/\/localhost";

然后你可以尝试:

$site = "http:"."/"."/"."localhost";

或者也:

$site = "http:".chr(47).chr(47)."localhost";

问候

于 2015-05-26T20:58:44.333 回答
0

据我所知,您希望将该$site变量用作页面中的链接,例如:

    <?php
    $site = "http://localhost";
    echo "<a href=\"$site\">sites</a>";
    ?>

就我的本地主机服务器而言,您的代码行似乎没有任何问题。可能是你没有正确地逃避某些事情,就像我的echo陈述一样,我不得不反斜杠我的报价。

于 2015-05-26T21:05:54.583 回答
0

在 PHP 中,双引号表示应该处理的文本。

所以

$v = 1;
echo "$v"; 

会给:1

但如果你

echo '$v';

你会得到:$v

尝试做:

$site = 'http://localhost';
于 2015-05-26T21:14:34.620 回答