PHP file extension question: please help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
catherine878
Forum Newbie
Posts: 6
Joined: Wed Jun 26, 2002 7:04 pm

PHP file extension question: please help!

Post by catherine878 »

Hi all,

I want to include a navigation menu (navig.html) in every page of a site. For example, I used the following code in an ABOUT page:

<?php
$fp=fopen ('navig.html',"r");
$menu=fread ($fp, 30000);
fclose($fp);
echo $menu;
?>

And it works, but I must have the file ABOUT saved as a PHP file instead of a regular HTML page. Is there anyway I can keep the HTML extension but still display the content from navig.html using the above code?

Many thanks!!!

Catherine
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Yes, just use an include() or require() function. It should work fine with an HTML extension on the end of the file.

However, I have a question. Are you using relative or absolute urls in the menu? How do you insure that the links are good from page to page?

Later on,
BDKR
catherine878
Forum Newbie
Posts: 6
Joined: Wed Jun 26, 2002 7:04 pm

But...

Post by catherine878 »

Require () works too, but if I save the file as HTML it still won't display anything... I don't know why.

Thanks !
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Yes, you have to edit the httpd.conf file of the Apache server to add it in.

If you don't have access to the httpd.conf file, then you are pretty much stuck. But why does it have to be .html and not .php?
Post Reply