【发布时间】:2013-06-03 09:09:18
【问题描述】:
我有 sendForm.php 文件,这是使用 PHPMailer 发送表单的 php。在标签之间有回声,我需要在标签之间使用 PHP 变量。这有可能吗?我知道将 PHP 和 JS 结合起来太过分了,但是我能做些什么……我需要一个弹出窗口,这就是我也使用 JS 的原因。回声本身只打印到网页本身。
$totalSize = ($totalSize/(1024*1024));
$totalSize = round($totalSize,2);
if(!$mail->Send()) {
echo "Error sending form! You are trying to send too large files. Their size is: ", $totalSize, " MB";
echo '<script type="text/javascript">alert("Error sending form! You are trying to send too large files. Their size is: ??? ");</script>';
}
如何在 JS 中打印 $totalSize 变量来代替第二个回显中的那些问号? 谢谢你的帮助。我还是个初学者。
【问题讨论】:
-
就像你在第一个 echo 中所做的那样?
-
echo '<script type="text/javascript">alert("Error sending form! You are trying to send too large files. Their size is: ', $totalSize, '");</script>';,没有? -
好吧,我已经尝试过了,它似乎以某种方式破坏了脚本 - 添加后窗口不会弹出。
-
将
Their size is: ??? ")更改为Their size is: $totalSize ") -
我不得不用 '. $totalSize。无论如何谢谢:)
标签: php javascript echo