Forum Moderators: coopster

Message Too Old, No Replies

php include function?

Newbie question, sorry!

         

The Cheap one

2:28 pm on Dec 3, 2006 (gmt 0)

10+ Year Member



I basically want my website in such a way that when I edit the php menu file once it will take effect for every other file like CSS. What would be the code to do this? Sorry again for the newbie question. Thank you in advance.

Frank_Rizzo

3:07 pm on Dec 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You just need something like this:

include('menu.php');

If you have sub directory pages then you'll need the full directory structure path such as

include('/home/mysite/menu.php');

Your menu.php must have <?php?>

<?php
menu here....
?>

mcibor

11:20 am on Dec 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would recomend

require_once('menu.php');

this way if you somehow will try to include the file twice there won't be any problems and no errors.

Michal

jatar_k

5:58 pm on Dec 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe try this thread from our PHP Library [webmasterworld.com]

A dynamic site in 2 minutes [webmasterworld.com]