Hi,
I'm trying to figure out how www.devshed.com does what I want to achieve
also, this is my point:

my main URL (for example) is www.mycompany.com
I want the central page about our projects to be found under
www.mycompany.com/projects
and project LovePeaceAndBananas under
www.mycompany.com/projects/LovePeaceAndBananas

I already know that this can be achieved by using the $PATH_INFO as
variables, to be used in de main file in the root of the site.
So far I have my Apache webserver accept files with no extention (index, in
stead of index.php) to be parsed as PHP. But if I look at the site of
DevShed, I don't see them using a file at all! I can't get it to work on my
local test system to make an URL like
www.mycompany.com/projects/LovePeaceAndBananas without the existens of a
file called 'projects'.
Can anyone tell me their 'trick'? (unfortunately, they don't show their page
source anymore like they used to do ...)

Also, when I try to extract the variabeles from the $PATH_INFO I get some
errors depending whether or not I end with a slash, and I do want to make
this fool prove, so that when a site visitor deletes the slash at the end,
it doesn't result in an error.

This is the code I made:
----------------------------------------------------------------------------
---
<?php
$var_array = explode("/",$PATH_INFO);
$words = array_unique ($var_array);
$total = count($words);
for ($i = 0; $i <= $total; $i++) {
    echo "variable " . $i . " = " . $var_array[$i]."<br>";
    }
?>
----------------------------------------------------------------------------
---


And when I call this file (localhost/index) like this:
http://localhost/index/one/two/three/

This is my output:
----------------------------------------------------------------------------
---
variable 0 =
variable 1 = one
variable 2 = two
variable 3 = three
variable 4 =
----------------------------------------------------------------------------
---

Ofcourse I don't need the variable 0 and 4, can someone tell me where they
come from?
And, as said above, I get an Undefined Ofset-warning when I don't have a
closing slash at the end, how can I protect this?

Phew -- a lotta lotta questions here, hope someone can help me to climb this
PHP-mountain:-)
Thanx in advance!
Dr.Bob




Reply via email to