/    Sign up×
Community /Pin to ProfileBookmark

get_file_contents own sever

I’m trying to get the HTML content from a template.

I have a page email_type_a.php for example. I want to get a copy of the HTML of this which includes run PHP scripts.

Then I want to place that into the “body” of my email PHP script before I send it.

get_file_contents just gets my raw PHP script which is not good of course.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 11.2020 — One option:
<i>
</i>ob_start();
include 'path/to/some/file.php';
$text = ob_get_clean();
// now you can insert $text where needed
Copy linkTweet thisAlerts:
@NogDogSep 11.2020 — PS: The above is assuming that the file being included normally outputs the HTML. If that file instead just saves the text to a variable, then you could just do the include and not have to worry about output buffering.

Probably the "best" approach would be to have the included (or required) file provide a function definition that the main file could call to get the text from.
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...