Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Include()

Featured Replies

Yes I will be pounding questions onto the PHP forum now as I try to understand the theory behind the coding etc.

 

I have been reading the W3C schools PHP tutorials, most of which has gone in.

 

Now I want to use the "include()" function on my pages as I am doing a site which the menu will change. I have included the coding in the pages and then uploaded it to my server.

Now the page loads but the menu doesn't appear.....

 

Suggestions?

 

Regards,

Junior

This should go in each page instead of the menu markup:-

<?php include ("menu.inc"); ?>

 

You create a page called menu.inc and put it in the same folder/directory as the main pages. It only needs the menu code that you cut out of the main pages like:-

<ul>
<li>.........</li>
<li>.........</li>
</ul>

 

no doctype, html tag, body tag, etc.

 

Name each main page with .php extension and check that your host supports PHP. You won't see the result on your computer from local files unless you have a server like Apache included in WampServer2. You should see the menu online if your host supports PHP.

  • Author

My host supports PHP I have run the test.php.

 

.inc not a .php like the tutorial I was reading said?

 

Regards,

Junior

 

Edit: I have got it working but now have another query.

 

I was using the Nifty corners js script and had it working is there a way to get these two working together?

My host supports PHP I have run the test.php.

 

.inc not a .php like the tutorial I was reading said?

 

Regards,

Junior

 

You can include any file such as menu.html, menu.php, menu.inc, as Wickam said save the code you want to include eg

 

<ul>

<li>.........</li>

<li>.........</li>

</ul>

 

I assume your menu code will be held in a div such as <div id="menu">

 

Then the whole code would be

 

<div id="menu">

<?php include 'menu.html'; ?>

</div>

 

 

 

 

 

 

I was using the Nifty corners js script and had it working is there a way to get these two working together?

 

 

A PHP include just substitutes code from one page into another, so it can work with any code. You sometimes have to be careful to get the paths correct if you have files in different folders, so start by keeping them all in the same folder/directory until you feel confident.

 

Using .inc for the "include" file just makes it easy to identify the "include" file(s) when you have lots of other php, html, txt files in the same folder.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.