php 解析错误:语法错误,意外的 T_CONSTANT_ENCAPSED_STRING 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18579217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
提问by tyler fearns
I'm new to coding and after hosting my site I got this error when checking to make sure my php contact form was working:
我是编码新手,在托管我的网站后,在检查以确保我的 php 联系表单正常工作时出现此错误:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on line 16
the php code is:
php代码是:
<?php
$subject="subject";
$message="$message";
$mail_from="$email";
$header="from: $name <$mail_form>";
$to='[email protected]';
$send_contact=mail($to,$subject,$message,$header);
if($send_contact){
echno "Thank You!" "<a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
}
else{
echno "ERROR";
}
?>
Any ideas on how I can fix this? Thank you in advance.
关于如何解决这个问题的任何想法?先感谢您。
回答by Bora
True format. echo
instead of echno
and fixed double quotes " "
真正的格式。echo
而不是echno
和固定双引号" "
if($send_contact){
echo "Thank You! <a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
} else {
echo "ERROR";
}
回答by Black Sheep
change this:
改变这个:
if($send_contact){
echno "Thank You!" "<a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
} else {
echno "ERROR";
}
to
到
if($send_contact){
echo "Thank You! "."<a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
// ^ Here the point
} else {
echo "ERROR";
}
or (Updated)
或(更新)
if($send_contact){
echo "Thank You! <a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
// ^ Eliminated double quotes
} else {
echo "ERROR";
}
Don't exist echno
and between the both string you forget the .
or to eliminate the " "
不存在echno
并且在您忘记.
或消除的两个字符串之间" "
回答by Bad Wolf
Your problem is with the following code
您的问题在于以下代码
echno "Thank You!" "<a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
^ ^ ^
echno "ERROR";
^
You either need to remove the two double quotes or concantinate the string with the .
operator.
您需要删除两个双引号或将字符串与.
运算符合并。
echo "Thank You! <a href='index.html' style='text-decoration:none; color:#4fa9b8;'> Return Home </a>";
Also echno
is not a thing, the correct name is echo
.
另外echno
是不是一个东西,正确的名称是echo
。