1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

help with php variable

Discussion in 'PHP' started by izlik, Aug 17, 2010.

  1. #1
    in my php file i currently have this

    $number = basename('http://'.$_SERVER['HTTP_HOST'].($_SERVER['REQUEST_URI'] == '/' ? 1 : $_SERVER['REQUEST_URI']));

    currently, if someone go to http://mypage.com/1 $number becomes 1, or any other number they type in. How can i do it so that if they go to http://mypage.com only $number becomes 1 automaticly?
     
    izlik, Aug 17, 2010 IP
  2. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #2
    just make it so that if $number is undefined set it to 1?
     
    MakZF, Aug 17, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    $number = basename('http://'.$_SERVER['HTTP_HOST'].($_SERVER['REQUEST_URI'] != 1 ? 1 : $_SERVER['REQUEST_URI']));
    PHP:
     
    danx10, Aug 17, 2010 IP
  4. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #4
    did not work :/ it sets everyting to 1 now, on http://mypage.com/22 $number becomes 1 when i print it.
     
    izlik, Aug 17, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    $number = basename('http://'.$_SERVER['HTTP_HOST'].($_SERVER['REQUEST_URI'] == '/' || trim($_SERVER['REQUEST_URI']) == '' ? 1 : $_SERVER['REQUEST_URI']));
    PHP:
     
    danx10, Aug 17, 2010 IP