if statement with url

This is a discussion on if statement with url within the PHP Language forums, part of the PHP Programming Forums category; Hi, How do I print different code depending on the URL? For instance: <? if url="page1.php" ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-09-2003
John
 
Posts: n/a
Default if statement with url

Hi,

How do I print different code depending on the URL?

For instance:

<?

if url="page1.php" then print("hi");
if url="page2.php" then print("hello");
if url="page3.php" then print("howdy");

?>

Thanks in advance :-)


Reply With Quote
  #2 (permalink)  
Old 09-09-2003
Andy Hassall
 
Posts: n/a
Default Re: if statement with url

On Tue, 9 Sep 2003 17:17:47 -0400, "John" <gt2243a@mail.gatech.edu> wrote:

>How do I print different code depending on the URL?
>
>For instance:
>
><?
>
>if url="page1.php" then print("hi");
>if url="page2.php" then print("hello");
>if url="page3.php" then print("howdy");
>
>?>


http://uk2.php.net/manual/en/reserve...riables.server
http://uk.php.net/manual/en/function.basename.php

--
Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Reply With Quote
  #3 (permalink)  
Old 09-09-2003
bugs
 
Posts: n/a
Default Re: if statement with url

John <gt2243a@mail.gatech.edu> wrote:

> <?


> if url="page1.php" then print("hi");
> if url="page2.php" then print("hello");
> if url="page3.php" then print("howdy");


> ?>


think abt this..

address: http://yoursite.com/page1.php
http://yoursite.com/page2.php
http://yoursite.com/page3.php

well if it either of these pages... you would know which page u are in
exactly.. cause the code needs to go in any one page..

so, i dont totally get what you want to achieve here
Reply With Quote
  #4 (permalink)  
Old 09-10-2003
Andy Hassall
 
Posts: n/a
Default Re: if statement with url

On 9 Sep 2003 21:32:03 GMT, bugs <bugs@myrna.cc.gatech.edu> wrote:

>John <gt2243a@mail.gatech.edu> wrote:
>
>> <?

>
>> if url="page1.php" then print("hi");
>> if url="page2.php" then print("hello");
>> if url="page3.php" then print("howdy");

>
>> ?>

>
>think abt this..
>
>address: http://yoursite.com/page1.php
> http://yoursite.com/page2.php
> http://yoursite.com/page3.php
>
>well if it either of these pages... you would know which page u are in
>exactly.. cause the code needs to go in any one page..
>
>so, i dont totally get what you want to achieve here


If they were all symbolic links to the same file, or the code in question was
run from an include file used by all three, then the question makes sense.

--
Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Reply With Quote
  #5 (permalink)  
Old 09-10-2003
Randell D.
 
Posts: n/a
Default Re: if statement with url


"John" <gt2243a@mail.gatech.edu> wrote in message
news:bjlg1i$gh5$1@news-int.gatech.edu...
> Hi,
>
> How do I print different code depending on the URL?
>
> For instance:
>
> <?
>
> if url="page1.php" then print("hi");
> if url="page2.php" then print("hello");
> if url="page3.php" then print("howdy");
>
> ?>
>
> Thanks in advance :-)
>
>


Use the value of $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] to
determine the name of your parent script... other variables like this can be
seen if you call phpinfo(); Examine the output but be aware that some of the
variables are optional (in such that some variables are created by the
client (ie your browser) and some browsers provide more information in its
headers then other browsers).


Reply With Quote
  #6 (permalink)  
Old 09-11-2003
John
 
Posts: n/a
Default Re: if statement with url

"Randell D." <you.can.email.me.at.randelld@yahoo.com> wrote in message
news:H0t7b.924842$ro6.18502319@news2.calgary.shaw. ca...
>
> Use the value of $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] to
> determine the name of your parent script... other variables like this can

be
> seen if you call phpinfo(); Examine the output but be aware that some of

the
> variables are optional (in such that some variables are created by the
> client (ie your browser) and some browsers provide more information in its
> headers then other browsers).
>
>


Thanks, that did it :-)


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0