PHP: 语法错误,意外标记“<” (<bold>)
PHP: syntax error, unexpected token "<" (<bold>)
我正在尝试通过 PHP 验证表单,但出现无法解决的语法错误(意外标记“<”)。这是代码。错误显然在第 4 行(第一个粗体):
<?php
if(isset($_POST['email'])) {
<bold>// Debes editar las próximas dos líneas de código de acuerdo con tus preferencias</bold>
$email_to = "xxxx";
$email_subject = "xxxx";
<bold>// Aquí se deberían validar los datos ingresados por el usuario</bold>
if(!isset($_POST['nombre']) ||
!isset($_POST['correo']) ||
!isset($_POST['xx']) ||
!isset($_POST['xx'])) {
echo "<b>Ocurrió un error y el formulario no ha sido enviado. </b><br />";
echo "Por favor, vuelva atrás y verifique la información ingresada<br />";
die();
}
$email_message = "Detalles del formulario de contacto:\n\n";
$email_message .= "Nombre: " . $_POST['nombre'] . "\n";
$email_message .= "Correo: " . $_POST['correo'] . "\n";
$email_message .= "xx: " . $_POST['xx'] . "\n";
$email_message .= "xx: " . $_POST['xx'] . "\n\n";
<bold>// Ahora se envía el e-mail usando la función mail() de PHP</bold>
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
echo "¡El formulario se ha enviado con éxito!";
}
?>
我已经在 php.ini 中将 Short Tag 编辑为“On”,但没有解决,我在这里没有看到什么?
<bold>
是 HTML,不是有效的 PHP 结构。
您可以在同一个文件中包含 HTML,尽管这通常不是最佳做法,除非它是一个模板,但您必须在写入前关闭 PHP 标签 (<?php ... ?><bold><?php ...
) HTML.
不过,我不确定您的 <bold>
标记在此代码中的用途。这似乎是一个疏忽。
我正在尝试通过 PHP 验证表单,但出现无法解决的语法错误(意外标记“<”)。这是代码。错误显然在第 4 行(第一个粗体):
<?php
if(isset($_POST['email'])) {
<bold>// Debes editar las próximas dos líneas de código de acuerdo con tus preferencias</bold>
$email_to = "xxxx";
$email_subject = "xxxx";
<bold>// Aquí se deberían validar los datos ingresados por el usuario</bold>
if(!isset($_POST['nombre']) ||
!isset($_POST['correo']) ||
!isset($_POST['xx']) ||
!isset($_POST['xx'])) {
echo "<b>Ocurrió un error y el formulario no ha sido enviado. </b><br />";
echo "Por favor, vuelva atrás y verifique la información ingresada<br />";
die();
}
$email_message = "Detalles del formulario de contacto:\n\n";
$email_message .= "Nombre: " . $_POST['nombre'] . "\n";
$email_message .= "Correo: " . $_POST['correo'] . "\n";
$email_message .= "xx: " . $_POST['xx'] . "\n";
$email_message .= "xx: " . $_POST['xx'] . "\n\n";
<bold>// Ahora se envía el e-mail usando la función mail() de PHP</bold>
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
echo "¡El formulario se ha enviado con éxito!";
}
?>
我已经在 php.ini 中将 Short Tag 编辑为“On”,但没有解决,我在这里没有看到什么?
<bold>
是 HTML,不是有效的 PHP 结构。
您可以在同一个文件中包含 HTML,尽管这通常不是最佳做法,除非它是一个模板,但您必须在写入前关闭 PHP 标签 (<?php ... ?><bold><?php ...
) HTML.
不过,我不确定您的 <bold>
标记在此代码中的用途。这似乎是一个疏忽。