SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot toma's Avatar
    Join Date
    Jul 2001
    Location
    Tempe, AZ
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using string functions

    Happy Thanksgiving all!

    If I use this to get the current URL
    PHP Code:
    $url $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"]; 
    How can I use string functions to strip off anything passed in a url such as ID's?
    I know I have to find the ? character and anything after it, and exclude those.

    Thanks much.

  2. #2
    SitePoint Zealot toma's Avatar
    Join Date
    Jul 2001
    Location
    Tempe, AZ
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about this
    PHP Code:
    $param strpos$url'?' );
    $url substr$url0$param ); 
    If I wrap this in an IF statement it seems to work
    PHP Code:
    if ($param) {
    $url substr$url0$param );

    without the if $url will be empty if there's nothing being passed with the url. (Obvious to some, I'm sure )

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    preg_replace
    cheers

  4. #4
    SitePoint Addict Chillijam's Avatar
    Join Date
    Nov 2003
    Location
    England
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not use

    PHP Code:
    $url $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["PHP_SELF"]; 
    ?
    Your mind is like a parachute. It works best when open.
    (HH The Dalai Lama)

  5. #5
    SitePoint Zealot toma's Avatar
    Join Date
    Jul 2001
    Location
    Tempe, AZ
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Chillijam
    Why not use

    PHP Code:
    $url $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["PHP_SELF"]; 
    ?
    I think that would work too - not sure which is better...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •