if statement with url

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    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 :-)


  • Andy Hassall

    #2
    Re: if statement with url

    On Tue, 9 Sep 2003 17:17:47 -0400, "John" <gt2243a@mail.g atech.edu> wrote:
    [color=blue]
    >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");
    >
    >?>[/color]




    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • bugs

      #3
      Re: if statement with url

      John <gt2243a@mail.g atech.edu> wrote:
      [color=blue]
      > <?[/color]
      [color=blue]
      > if url="page1.php" then print("hi");
      > if url="page2.php" then print("hello");
      > if url="page3.php" then print("howdy");[/color]
      [color=blue]
      > ?>[/color]

      think abt this..

      address: http://yoursite.com/page1.php
      This website is for sale! yourcompany.com is your first and best source for all of the information you’re looking for. From general topics to more of what you would expect to find here, yourcompany.com has it all. We hope you find what you are searching for!

      This website is for sale! yourcompany.com is your first and best source for all of the information you’re looking for. From general topics to more of what you would expect to find here, yourcompany.com has it all. We hope you find what you are searching for!


      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

      Comment

      • Andy Hassall

        #4
        Re: if statement with url

        On 9 Sep 2003 21:32:03 GMT, bugs <bugs@myrna.cc. gatech.edu> wrote:
        [color=blue]
        >John <gt2243a@mail.g atech.edu> wrote:
        >[color=green]
        >> <?[/color]
        >[color=green]
        >> if url="page1.php" then print("hi");
        >> if url="page2.php" then print("hello");
        >> if url="page3.php" then print("howdy");[/color]
        >[color=green]
        >> ?>[/color]
        >
        >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[/color]

        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)

        Comment

        • Randell D.

          #5
          Re: if statement with url


          "John" <gt2243a@mail.g atech.edu> wrote in message
          news:bjlg1i$gh5 $1@news-int.gatech.edu. ..[color=blue]
          > 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 :-)
          >
          >[/color]

          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).


          Comment

          • John

            #6
            Re: if statement with url

            "Randell D." <you.can.email. me.at.randelld@ yahoo.com> wrote in message
            news:H0t7b.9248 42$ro6.18502319 @news2.calgary. shaw.ca...[color=blue]
            >
            > Use the value of $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] to
            > determine the name of your parent script... other variables like this can[/color]
            be[color=blue]
            > seen if you call phpinfo(); Examine the output but be aware that some of[/color]
            the[color=blue]
            > 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).
            >
            >[/color]

            Thanks, that did it :-)


            Comment

            Working...