Single page website - question about article

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jennifer_v
Forum Newbie
Posts: 3
Joined: Wed Jun 25, 2003 2:04 pm

Single page website - question about article

Post by jennifer_v »

Hi everyone!!

I am very new to PHP and I found an article (http://www.evilwalrus.com/articles.php?aid=29) on this site about having all pages on one single webpage.
The article is explained really well and it's just what I was looking for. But I do have one problem and I would be very greatful if someone could help me with this:
I don't understand this:
<?php
ini_set('include_path', '/path/to/your/site');
switch ($_GET['page']) {
default:
include('home.php');
break;
}
?>

What is a path? And how do I specify it in the code? Like I said, I'm really a beginner, so please don't judge me if this is stupid question ;)

Thanks!!
Jennifer
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

path to your site, or basically, which directory your site is in.

So, let's say my site was in this directory:

/home/jason/public_html

That would be the path to my site.

It would look like this:

Code: Select all

<?php
ini_set('include_path', '/home/jason/public_html');
switch ($_GET['page']) {
default:
include('home.php');
break;
}
?>
jennifer_v
Forum Newbie
Posts: 3
Joined: Wed Jun 25, 2003 2:04 pm

Post by jennifer_v »

Hi,


Thanks for replying. I'm sorry I didn't reply until now, but I had a lot of trouble with my computer after someone installed a new program.
What should I call the path if it's just in the basic directory? If I just upload the files, without making a directory? Is it called home then?
I know this is really stupid, but I tried every evening of the last 5 days to make it work and it doesn't. I'm pretty sure that the problem's with the directory I named.

Thanks!!
Jennifer
User avatar
PaTTeR
Forum Commoner
Posts: 56
Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:

Post by PaTTeR »

This path must be full path to your folder. If you are on Windows box you should use Windows style path - C:\your\files , if you are oh Unix (Linux) box - /your/files

For better explain see this:
http://php.net/manual/en/configuration. ... clude-path
jennifer_v
Forum Newbie
Posts: 3
Joined: Wed Jun 25, 2003 2:04 pm

Re:

Post by jennifer_v »

Thanks for your answers everyone!!
But I still don't get it :( Please don't judge me, I'm normally not that stupid :oops:

I realize how annoying I must be, but this is the tutorial I've been looking for for ages. I' searching for the solution for so many days now, so any help is really really appreciated.

I have 2 questions:
This path must be full path to your folder. If you are on Windows box you should use Windows style path - C:\your\files , if you are oh Unix (Linux) box - /your/files
I don't test the PHP files offline, I immediately test them online, so does the C:\...\... work? Let's say that my files are hosted a Geocities (I know they don't support php, but that doesn't really matter). Should I then use the directory of the files there? Like for example, if I have a map 'files' and there the files are located in, then the directory is just 'files', or should I use the directory of my compueter, even if they don't have the same kind of .../.../... as the one on my computer?

And my second question: I tried to try out this tutorial just by copying the files described in the tutorial. And then I made an home.php, about.php,...
Should I also put something else in the index file or edit something (besides '/path/to/your/site' and 'about.php'?)
I copied this:

<?php
ini_set('include_path', '/path/to/your/site');
switch ($_GET['page']) {
case 'about':
include('about.php');
break;
case 'default':
include('home.php');
break;
}
?>
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You only really need to use ini_set for your includes() if a:you have different pages in different folders on your site which all require the same include() files, and b:.... well there isn't a b really.

If you are planning to create a 'single' page website like you suggest (this seems all the rage at the moment but I can't see the point of it really) then all you need to do is make sure you know where your include() files are relative to the main page.

For example...

This example presumes you have your include() files in a folder called 'inc', and the folder is in the same place as your index page.

Code: Select all

<?php
include('inc/a_file.php');
?>
... and that's it!

If you have your include() files in the same place as your index page just use..

Code: Select all

<?php
include('a_file.php');
?>
You are making things difficult for yourself with all of that extra code :)
Post Reply