PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > website tree
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
website tree

Réponse
 
LinkBack Outils de la discussion
Vieux 05/01/2008, 17h06   #1
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut website tree

Hi,

let's imaging we have the following thing :

www.mywebsite.com/company/index.php
www.mywebsite.com/company/profile.php
www.mywebsite.com/services/index.php

how can i detect in which address am i ?

for example how to retrieve www.mywebsite.com/services or
www.mywebsite.com/company

--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 05/01/2008, 17h18   #2
John Gunther
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: website tree

Get the various parts from the $_SERVER superglobal variable:
1) scheme (e.g. http://) from $_SERVER['HTTPS'] (https if "on")
2) host:port (e.g. bucksvsbytes.com) from $_SERVER['HTTP_HOST']
3) /path/page?query part (e.g. /catalog/index.php?pid=444) from
$_SERVER['REQUEST_URI']

John Gunther
Alain Roger wrote:
> Hi,
>
> let's imaging we have the following thing :
>
> www.mywebsite.com/company/index.php
> www.mywebsite.com/company/profile.php
> www.mywebsite.com/services/index.php
>
> how can i detect in which address am i ?
>
> for example how to retrieve www.mywebsite.com/services or
> www.mywebsite.com/company
>

  Réponse avec citation
Vieux 05/01/2008, 17h25   #3
Daniel Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] website tree

On Jan 5, 2008 12:06 PM, Alain Roger <raf.news@gmail.com> wrote:
> Hi,
>
> let's imaging we have the following thing :
>
> www.mywebsite.com/company/index.php
> www.mywebsite.com/company/profile.php
> www.mywebsite.com/services/index.php
>
> how can i detect in which address am i ?
>
> for example how to retrieve www.mywebsite.com/services or
> www.mywebsite.com/company


<?
preg_match('/\/(.*)\//',$_SERVER['REQUEST_URI'],$match);
echo $match[1];
?>


--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.
  Réponse avec citation
Vieux 07/01/2008, 01h54   #4
Breno
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: website tree

Alain Roger escreveu:
> Hi,
>
> let's imaging we have the following thing :
>
> www.mywebsite.com/company/index.php
> www.mywebsite.com/company/profile.php
> www.mywebsite.com/services/index.php
>
> how can i detect in which address am i ?
>
> for example how to retrieve www.mywebsite.com/services or
> www.mywebsite.com/company
>


There are many methods like using the $_SERVER variable (auto generated)

$_SERVER['REQUEST_URI'] or $_SERVER['SCRIPT_NAME']

Try this and tell us

Breno
  Réponse avec citation
Vieux 08/01/2008, 18h33   #5
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] website tree

At 6:06 PM +0100 1/5/08, Alain Roger wrote:
>Hi,
>
>let's imaging we have the following thing :
>
>www.mywebsite.com/company/index.php
>www.mywebsite.com/company/profile.php
>www.mywebsite.com/services/index.php
>
>how can i detect in which address am i ?
>
>for example how to retrieve www.mywebsite.com/services or
>www.mywebsite.com/company
>
>--
>Alain

------------------------------------

Allan:

I think I see where you are going with this -- try this:

http://sperling.com/examples/smart-menu/


Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 08/01/2008, 19h09   #6
Richard Heyes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Re: website tree

John Gunther wrote:
> Get the various parts from the $_SERVER superglobal variable:
> 1) scheme (e.g. http://) from $_SERVER['HTTPS'] (https if "on")
> 2) host:port (e.g. bucksvsbytes.com) from $_SERVER['HTTP_HOST']
> 3) /path/page?query part (e.g. /catalog/index.php?pid=444) from
> $_SERVER['REQUEST_URI']


There's also $_SERVER['PHP_SELF']. Probably others too. Simply:

<?php
print_r($_SERVER);
?>

This will show you what's available to you.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Desk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15068 seconds with 14 queries