PHP Include help

This may double post so sorry if it does…

Anyway I am teaching myself php by using a template and amending it.

I am having problems getting the include function to work.

In the index file I have:

hello
  • Navigation <? php require ("menu.php"); ?>
  • The text hello and navigation were entered so I could check the positioning.

    Any idea why this isn’t pulling through my menu file?

    Thanks

    Sorry tht should have said:

    hello
  • Navigation <? php include("menu.php"); ?>
  • (include not require)

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

    you put space at the <?php misstasham…

    Thanks for the reply

    I tried that it doesnt work… any other sugestions?

    Both include and require should work fine. But you need to check two more things:

    • your menu.php file must be located in the same directory as your file with the code you posted here
    • check for syntax errors in your menu.php file (or, for testing purposes, just place there some static text)

    Hi

    I’ve checked both of those things and its still not working, there were a couple of syntax errors before which I have now amended but its still not pulling through what I need…

    Did you try to put static text in menu.php? Like this:
    menu.php

    Hello world!

    If after that it is still not working, check your file extension (or mime type) - must be php. And check if you have PHP installed, and web server is running (such as Apache).

    Right I have tried everything you have suggested… the test file works.

    Also tried entering plain text into the menu file and its still not pulling through…

    Thanks for your suggestion

    Sponsor our Newsletter | Privacy Policy | Terms of Service