Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在电子邮件中包含一个php文件_Php_Email_Include - Fatal编程技术网

在电子邮件中包含一个php文件

在电子邮件中包含一个php文件,php,email,include,Php,Email,Include,嘿,我这里有一段代码,我正在尝试将这个html文件中的内容包含到一封电子邮件中,但它似乎不起作用:(mime类型可以吗?php是否包含我想要的内容 $to = "email@domainname.com"; $subject = "Late Notice"; $message .= include("latenotice.html"); $from = "myfriend@hisdomainname.com"; $h

嘿,我这里有一段代码,我正在尝试将这个html文件中的内容包含到一封电子邮件中,但它似乎不起作用:(mime类型可以吗?php是否包含我想要的内容

        $to = "email@domainname.com";
        $subject = "Late Notice";
        $message .= include("latenotice.html");
        $from = "myfriend@hisdomainname.com";
        $headers = "From:" . $from;
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        mail($to,$subject,$message,$headers);
如果希望在包含后“返回”某些内容,则需要在包含的文件末尾添加一个返回

比如file.php

 return "My String";
Email.php

$var = include('file.php'); // "My String"
在您的情况下,请使用。

如果您希望在包含后“返回”某些内容,则需要在包含的文件末尾添加一个返回

比如file.php

 return "My String";
Email.php

$var = include('file.php'); // "My String"

在您的情况下,请使用。

include
仅当包含的文件
return
s something-
latenotice.html
可能仅包含内容时才计算为值。我想您应该阅读该文件:

$message .= file_get_contents("latenotice.html");

include
仅当包含的文件
return
s something-
latenotice.html
可能只包含内容时,才会计算为一个值。我想您应该阅读该文件:

$message .= file_get_contents("latenotice.html");
不返回字符串,它在脚本中包含可执行代码

您可能正在寻找:

此外,您还应该查看PEAR库,如:附件和mime类型不是简单的,要获得正确的结果。

不返回字符串,它在脚本中包含可执行代码

您可能正在寻找:


此外,您还应该查看PEAR库,如附件和mime类型。正确地说,附件和mime类型并不简单。

include
不返回字符串。它执行文件,这意味着HTML将回显到屏幕上

请尝试
文件\u获取\u内容

$message .= file_get_contents("latenotice.html");
注意:这将不执行文件中的任何PHP代码。如果需要,可以使用输出缓冲

ob_start();
include("latenotice.html");
$message .= ob_get_clean();

include
不返回字符串。它执行文件,这意味着HTML将回显到屏幕上

请尝试
文件\u获取\u内容

$message .= file_get_contents("latenotice.html");
注意:这将不执行文件中的任何PHP代码。如果需要,可以使用输出缓冲

ob_start();
include("latenotice.html");
$message .= ob_get_clean();

Include打开并计算文件。您可能需要类似于fopen()的内容。@j08691:file\u get\u contents更容易。Include打开并计算文件。您可能需要类似于fopen()的内容相反,@j08691:file\u get\u contents更容易。除非有东西要返回,否则返回什么也不做。
return;
本身不包括文件的源代码。除非有东西要返回,否则返回什么也不做。
return;
本身不包括文件的源代码。谢谢火箭,它的工作很有魅力;)我能在5分钟内接受汉克斯火箭,像个魔咒一样工作;)5分钟后我就可以接受了