• Be sure to join the discussion on our discord at: Discord.gg/serebii
  • If you're still waiting for the e-mail, be sure to check your junk/spam e-mail folders

PHP includes help needed!

Magma Leader Maxie

Non caedor caedo
Try this instead:

Code:
// if head.html and your php file are in the same directory
<?php require('./head.html'); ?>

// if head.html is in another diretory called "dir"
<?php require('./dir/head.html'); ?>

// if head.html is somewhere on the net :)
<?php require('http://www.site.com/head.html'); ?>
 

Magma Leader Maxie

Non caedor caedo
Then try the getcwd() function.

Code:
define('DIR', ($cwd=getcwd()? $cwd, '.'));
require(DIR . 'PATH_TO_FILE');
where PATH_TO_FILE is the local path to whatever you're including.
 

♪Crystal Mew♪

Mr. ▒▒▒▒▒▒▒
since they aren't dynamic files did you try something like this?

Code:
echo file_get_contents('header.html');

did you also try:
Code:
include('header.html');
 

Magma Leader Maxie

Non caedor caedo
♪Crystal Mew♪ said:
since they aren't dynamic files did you try something like this?

Code:
echo file_get_contents('header.html');

did you also try:
Code:
include('header.html');

No real need to use file_get_contents()... plus there have been some incompatibility issues with that function, depending on the PHP version.

If require didn't work, include won't either. They are related functions.

If all else fails, ask your host to give you the full relative path to your directory (for example www\root\xy\htdocs) and then use that to require the file. But I think that ♪Crystal Mew♪'s suggestion to use include() makes sense because usually, only vital program components (such as class files, for example) need to be required. However, it's a good practice to use the './' before the filename if the file is in the same directory, or '../' if it's in one directry lower, etc.
 
Top