Include() help

Hi, im setting up my website to just have one index.php, and the content it delivers based on a variable p that’s passed through the url, like this:

http://www.website.com/index.php?p=index | http://www.website.com/index.php?p=other

I have it set so that index.php includes display.php with this at the top of the index.php file:

<?php include "display.php"; ?>

Then in display I have:

<? $page = $_GET['p']; ?>

---- Now here’s where I run into my problem.

When I make a call to $page from index.php, it shows up as its passed through the url, IE, http://www.website.com/index.php?p=index

With: <? echo $page; ?> showing ‘index’ on the document.

But when I set up a function in display.php:

<? function display() { echo $page; }

And I put a call to that in index, page is left empty.


I guess its the way include() works, but I thought that it basically took all the text from display.php and processed it as if it were in index.php, but I guess that’s not the case if $page isn’t showing up.

Any ideas?

Nevermind, I figured it out, I didn’t know php needed to define local variables as global inside functions first.

Sponsor our Newsletter | Privacy Policy | Terms of Service