/    Sign up×
Community /Pin to ProfileBookmark

Need to require HTML file within PHP

I need to require a file containing HTML code in my PHP file. Since ‘require_once’ requires PHP to be active, how do I turn PHP off so that my HTML will work correctly? I tried adding ?> at the start of the required HTML file, but this seems so crude. I’m sure there must be a better way to handle this.

Any help would be welcome. Thanks.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsDec 30.2005 — ....what are you talking about? Last time I checked, including or requiring files simplying ended the current block of php, injected them, and then restarted php, which is why all includes need to start with <?php and end correctly.
Copy linkTweet thisAlerts:
@acorbelliDec 30.2005 — 
When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.
[/QUOTE]

Taken from:

http://us3.php.net/manual/en/function.include.php
Copy linkTweet thisAlerts:
@JazzcatCBauthorDec 30.2005 — Thank you folks. Sorry for my ignorance. I understand it better now.
Copy linkTweet thisAlerts:
@acorbelliDec 30.2005 — It's cool, no need to apologize. We all have questions.
×

Success!

Help @JazzcatCB 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...