Jump to content

including a file across multiple pages...


tefuzz

Recommended Posts

i have just begun to dabble in php and the first thing i am trying to tackle is getting certain variables available on any page the user visits..must i have (see below) at the top of every file or is there away to make it so that no matter what page the viewer is on the variables defined in test.php are available? is this a session issue, am i getting over my head or...?

 

<?php include('test.php'); ?>

 

thanks for helping a noob ;)

Link to comment
Share on other sites

I'm curious how to use a file in all pages on a website without using an include or require line at the beginning of every page...basically i'm looking to have a single index page be template driven, but if the user moves to another page maintain the template, and be able to access any function on any page. kind of like how when using wordpress, you enter the database info into the config file, and no matter what page you are on it can still connect to the database

Link to comment
Share on other sites

I run the whole site off index.php, and just switch out data where it's needed :D.

 

ok so something like this, i was just discussing this in another thread (http://www.phpfreaks.com/forums/index.php/topic,239825.0.html) is this kinda the same scenario?. a user clicks a link, and there's a value passed like 'index.php?action=contact' and you would load the contact data into the page upon reloading?

 

i was thinking of having the same thing for my site to keep are there any examples of this around? and what exactly is this called? how would i search for it say, on Google? does this use an outside functions page and config so that on reload it would call the right function which would load the right page data? 

 

am i getting over my head for a beginner with something like this? it doesn't seem all that hard, but im sure it's more than what it looks.

Link to comment
Share on other sites

 

Using that wouldn't it be a gigantic file size to include all of the possible cases? I mean. if i had index.php?action=contact and then have the entire contact page code after it? if i had 8 different links at the top and then had 8 different sets of data below it that could possibly be loaded.

 

Is it that involved/difficult to make it call a function like get_contact(); which would load the contents of contact.php and place it into the page for you?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.