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" ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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) |
|
|||
|
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 |
|
|||
|
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) |
|
|||
|
"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). |
|
|||
|
"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 :-) |