使用php include 功能将php文件包含到另一个中,我正在使用基于 wordpress 的网站,我正在构建一个电子邮件表单, php邮件。 对于我的主根文件夹中的文件,我可以使用函数 get_template_part(),但如果他的文件在子文件夹中,则此函数不起作用,因此使用包含功能,但我的路径有问题,我不知道为什么include功能不接受bloginfo('template_url')功能,任何人都可以帮助我吗?这是我的代码:
<?php
$template_url = bloginfo('template_url');
$url_mailer = $template_url . '/phpmailer/PHPMailerAutoload.php';
include '/phpmailer/PHPMailerAutoload.php';
//require $url_mailer;
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtps.aruba.it'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'postmaster@laveraitalia.us'; // SMTP username
$mail->Password = 'r2fmee2k'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = $email;
$mail->FromName = $name . $surname;
$mail->addAddress($reciver); // Add a recipient
$mail->addReplyTo($email, $name . $surname);
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if (!$mail->send()) {
$logmessage = "<span class=\"bg-danger\">The message hasn't been sent, try again</span>";
} else {
$logmessage = "<span class=\"bg-success\">The message has been sent</span>";
}
?>