PDA

View Full Version : require


gsnedders
03-10-2004, 08:28 PM
How can I make links in require ('/generalforum/'); not load a page with only that in but keep everything around them to stay the same.

piz
03-10-2004, 08:47 PM
hm... sorry, but I didn't understand anything...
What do you want to know?

gsnedders
03-10-2004, 09:18 PM
Say you've got that PHP script in your web page with lots of other things in the page, you want the links from the require to be put where the original page from the require was but leaving everything around them.

mordred
03-10-2004, 09:24 PM
I'm afraid I don't understand your question either. What links do you mean - are you refering to the path used as a parameter to require? And why does that not leave things as they were?

Require makes nothing else than opening a file, geting it's contents, and putting them into your script. If the file contained PHP, this PHP code gets executed. If not, the required file gets sent as output to your client/browser, along with the rest of your script's output.

gsnedders
03-10-2004, 10:46 PM
Alright, pretend this is our PHP page <?PHP

require ('header.php');
require ('content.php');
require ('footer.php');

?>and it produces <html>
<head>
<title>You get it</title>
</head>
<body>
<!-- End header.php -->
<!-- Start content.php -->
<p><a href="index.php">Home Page</a></p>
<!-- End content.php -->
<!-- Start footer.php -->
</body>
</html>but we want the link in content.php to open header.php at the top and footer.php at the bottom, so it is as if it opens with everything around it staying the same.

mordred
03-10-2004, 11:34 PM
If the script with the 3 requires is called index.php, everything will work as you said. My brain my be a little fried right now, but I still don't get the problem.

EDIT: Perhaps I'm getting nearer... each page that you open from a link in content.php must contain require()s to header.php and footer.php too to get them displayed. Is that what you're asking?

gsnedders
03-10-2004, 11:52 PM
Originally posted by mordred
EDIT: Perhaps I'm getting nearer... each page that you open from a link in content.php must contain require()s to header.php and footer.php too to get them displayed. Is that what you're asking? You've got it!

gsnedders
03-13-2004, 08:52 PM
Could this be done by using require ('header.php');
require ({REQUESTED-URI});
require ('footer.php');
If so, how could I use this?