【发布时间】:2013-04-05 17:34:43
【问题描述】:
好的,原来的建议似乎奏效了。他们没有像以前那样的错误代码。但现在它告诉我它的结局并不好。我尝试了多种语法,但似乎没有任何效果。和一个 IF 把它拿走......甚至删除 <? end if ?> 或诸如此类的东西。有什么想法吗?
<?php
$correct = true;
if ($_GET["firstname"] == "")
$correct = false;
if (preg_match("/^.+@\w+\.\w{2,4}$/", $_GET["email"]))
$correct = false;
$to = "sample@domain.com";
$subject = "Application request";
$message = "A new request has come in!\n\n";
$message .= $_GET["firstname"];
$message .= $_GET["lastname"];"\n";
$message .= $_GET["email"];"\n";
$message .= $_GET["phone"];"\n";
$message .= $_GET["dropdown"];"\n";
$message .= $_GET["address"];"\n";
$message .= $_GET["dropdown2"];"\n";
$message .= $_GET["textarea"];"\n";
?>
<html>
<head>
<title>something funky
</title>
</head>
<body>
<?php if ($correct): ?>
Thank you for applying. We will get back to you shortly.<br>
<?php else: ?>
Please complete the form.
<?php end ?>
</body>
</html>
【问题讨论】:
-
为什么这么反对大括号?
-
我从未见过像 PHP 的 这样的语法。你确定是对的吗?
-
@CodeMonkey 是一个有效的语法
-
@CodeMonkey:是的:php.net/manual/en/control-structures.alternative-syntax.php
-
你只需要用
endif;关闭你的if语句
标签: php