PHP Navagation HelpNavigation Help
Page 1 of 1
4 Replies - 1637 Views - Last Post: 21 July 2001 - 08:38 PM
#1
PHP Navagation Help
Posted 21 July 2001 - 07:39 PM
On some sites, they have a PHP file, and the little navagation thing is always on every page you look at that is linking to that php file. So If I wanna change the little navagation thing I can change the PHP file and it will change on every page. Does anyone know what I am talking about?
I probably just confused everyone.
Replies To: PHP Navagation Help
#2
Re: PHP Navagation Help
Posted 21 July 2001 - 07:55 PM
let me track down a tutorial for you
and I'll let you know in a few
#3
Re: PHP Navagation Help
Posted 21 July 2001 - 08:09 PM
<HTML>
<HEAD>
<TITLE>This is my page!</TITLE>
</HEAD>
< BODY>
HTML code... <? require("nav.inc"); ?> ...HTML code... <? PHP code ?> ...HTML code... etc...
</BODY>
</HTML>
The require expression tells the server to stick in the contents of the file named "nav.inc", instead of the PHP tag. Let's say this file contains the main navigation table for your site and looks like this:
this is the beginning of the file
<TABLE CLASS="nav">
<TR>
<TD><A HREF="/" TITLE="Home page">Home</A></TD>
<TD><A HREF="/computers/" TITLE="Everything about computers">Computers</A></TD>
...
</TR>
</TABLE>
the file ends here
This is what the server sends to the browser:
<HTML>
<HEAD>
<TITLE>This is my page!</TITLE>
</HEAD>
<BODY>
HTML code...
<TABLE CLASS="nav">
<TR>
<TD><A HREF="/" TITLE="Home page">Home</A></TD>
<TD><A HREF="/computers/" TITLE="Everything about computers">Computers</A></TD>
...
</TR>
</TABLE>
...more HTML code... <? PHP code ?> ...HTML code... etc... </BODY>
Again, the browser has no idea that PHP exists.
More about includes
As it should be clear from the example above, an include is a simple ASCII file, and there is no special "dressing" to put around it. Just cut out a chunk of HTML from a page and stick it in a separate file: you have an include.
Include files can have any extension. You can name an include "blahblah.bla" if you wish.
It is common to name them "something.inc", but using other extensions can sometimes make sense. For example, a file with a ".txt" extension will be viewable directly in most browsers, whereas trying to view includes with other extensions may simply result in the browser prompting you to "save as...". I have often used ".des" for some of my files to indicate that they were "design" files. Naming includes is a perfectly personal choice.
The require function replaces itself with the contents of the file it calls, whereas include is more like a branch that points to it. This can make a difference if you are using a loop to call different includes: if you use require, the statement will be replaced by the first file during the first loop, and you will end up with (e.g.) three times the same file instead of three different files. If you are not quite sure which to choose, follow this rule of thumb: In control statements and functions, use include. Otherwise, use require (which is supposed to be a little faster).
An include can call another include. The include is read just as a normal PHP file, which means that you can put in an include anything that you would put in a "normal" PHP file.
Calling an include with relative or server-relative urls sometimes creates trouble. I haven't quite sorted out this question yet, and will update this tutorial as soon as I have. Until then, if problems persist, use absolute urls, of the form "http://www.users.f2s.com/test/support/whatever/myfile.inc". And let me know if you have solved the problem!
You may also try this link:
http://www.phpbuilde...ll20001122.php3
#4
Re: PHP Navagation Help
Posted 21 July 2001 - 08:18 PM
http://www.tkohnen.com
#5
Re: PHP Navagation Help
Posted 21 July 2001 - 08:38 PM
and replace it with the include tag from above then in the .inc file put the HTML from the nav
|
|

New Topic/Question
Reply




MultiQuote




|