我有一个运行良好的PHP代码。我想向管理员发送一封电子邮件,说user - A
已提出请求。当我查看电子邮件时,会显示user -
。它不显示用户名。
PHP代码:
<?php
require 'PHPMailerAutoload.php';
$username = $_SESSION ["username"];
function leave_mail($user, $message){
//Some connection and credentials for the gmail
$username = $_SESSION ["username"];
$mail = new PHPMailer;
leave_mail($username, "Your message has been sent to the <b>admin.</b>");
leave_mail('amberTAG.adm@gmail.com', 'This message is to notify that you have a <b>new leave request</b> from <i><b>USER - <?php echo $username;?></b></i>');
?>
请帮忙!
答案 0 :(得分:-2)
'xxx' . $username . 'yyy'
那是因为你所写的已经是php代码了。所以string concat
是php中的<?php xxx; ?>
。
何时使用.php
?在编写<html>
<body>
<div>hello i am html</div>
<?php for($i=0;$i<5;++$i)echo 'Hey this is php code'; ?>
</body>
</html>
文件时,您默认编写html代码。所以当你想写php时,请使用它。
示例:
loaders: [
{ test: /\.scss$/, loaders: ['style', 'css', 'postcss', 'sass'] },
{ test: /\.(woff2?|ttf|eot|svg)$/, loader: 'url?limit=10000' },
// Bootstrap 4
{ test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery' }, ...]