当我进入时:
$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.";
我认为问题可能是我的localhost未设置为发送电子邮件。如果页面实际上在网上并且我使用了“$ site”变量的真实URL,那么这会有效吗?
答案 0 :(得分:0)
这应该可以解决问题,但输出会受到影响,所以它不是解决方案:
$site = "http:\/\/localhost";
然后你可以尝试:
$site = "http:"."/"."/"."localhost";
或者:
$site = "http:".chr(47).chr(47)."localhost";
问候
答案 1 :(得分:0)
据我所知,您希望将$site
变量用作页面中的链接,例如:
<?php
$site = "http://localhost";
echo "<a href=\"$site\">sites</a>";
?>
就我的localhost服务器而言,这里的代码行似乎没有任何问题。可能是你没有正确地逃避某些事情,就像我的echo
声明一样,我是否必须反驳我的报价。
答案 2 :(得分:0)
在PHP中,双引号表示应该处理文本。
所以
$v = 1;
echo "$v";
将给出:1
但如果你
echo '$v';
您将获得:$ v
尝试做:
$site = 'http://localhost';