/    Sign up×
Community /Pin to ProfileBookmark

require or include in the <head>?

hi, i have huge <head></head> sections that i’d like to be able to have as a separate file…is is possible to have a require or include php function in the <head></head> to replace all the code?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYSep 09.2005 — yes you can do that

in a separate file called for example head.php
[code=php]
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
...
</head>
[/code]


and on the main page you would go like
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<?php
include "head.php";
?>
<body>
...
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@bokehSep 09.2005 — I agree as above but putting your includes in a non public directory is best so they don't get indexed by search engines or worse.

[code=php]define('FILES', $_SERVER['DOCUMENT_ROOT'].'/../templates/');
include(FILES.'head.php');[/code]
×

Success!

Help @fonduelover 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.29,
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,
)...