将 PHP 页面的 html 响应返回到变量中
问题描述
我正在尝试使用通过另一个 PHP 文件创建的一些 HTML 生成一封电子邮件.
I am trying to generate an email with some HTML that is created via another PHP file.
电子邮件生成文件由每小时运行的 cron 运行.存在另一个文件,该文件生成电子邮件所需的 HTML.
Email generating file is run by a cron running every hour. Another file exists that generates the HTML required for the email.
HTML 生成文件没有我可以调用的函数,例如:
The HTML generating file does not have a function that I can call, for instance:
HTML 生成文件旨在包含在您希望显示 HTML 的页面上,例如:
The HTML generating file was designed to be included on a page that you wished to display the HTML, for instance:
我的问题是:我怎样才能将 htmlgenerator.php 文件返回到变量中,准备好推送到电子邮件中.
My question is: How can I get what the htmlgenerator.php file returns in to a variable, ready to be pushed in to an email.
抱歉,如果这不是很清楚,我很乐意回答任何问题.
Apologies if this is not very clear, I will be happy to answer any questions.
提前致谢!
推荐答案
如果我明白你说的,你可以使用输出缓冲,这样就可以得到 htmlGenerator.php
If I understood what you said, you can use output buffering,
so that you can get the output of htmlGenerator.php
例如:
你也可以像这样创建一个简单的函数:
You can also create a simple function like this:
阅读 php 文档了解更多详情.
Read the php documentation for further details.
这篇关于将 PHP 页面的 html 响应返回到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!