469,366 Members | 2,254 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

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 :-)
Jul 16 '05 #1
5 12825
On Tue, 9 Sep 2003 17:17:47 -0400, "John" <gt*****@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 (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #2
John <gt*****@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
Jul 16 '05 #3
On 9 Sep 2003 21:32:03 GMT, bugs <bu**@myrna.cc.gatech.edu> wrote:
John <gt*****@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 (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #4

"John" <gt*****@mail.gatech.edu> wrote in message
news:bj**********@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).
Jul 16 '05 #5
"Randell D." <yo**************************@yahoo.com> wrote in message
news:H0***********************@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 :-)
Jul 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Fábio Mendes | last post: by
13 posts views Thread by eman1000 | last post: by
37 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by Steven Bethard | last post: by
28 posts views Thread by Steven Bethard | last post: by
7 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by dspfun | last post: by
23 posts views Thread by florian.loitsch | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.