Results 1 to 8 of 8

Thread: is any function/property in PHP like js:location.href

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default is any function/property in PHP like js:location.href

    is any function/property in PHP like js:location.href, to give the current url, to get compared, for producing highlight menu items ?
    a local php server in a laptop needs internet connection to work locally only ?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I got the redirect part, but can you rephrase the rest of it?

    To redirect in php:
    Code:
    <?php
    header("Location: location.php");
    ?>
    Jeremy | jfein.net

  3. #3
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    I do NOT Redirection but a statement that assigns current URL To a var like javascript's location.href ?

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    So you have a button - and when you click it it will take you some where? Or, it will tell you the URL of the page your currently at?
    Jeremy | jfein.net

  5. #5
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    Will this variable be good for you?
    PHP Code:
    $_SERVER['SCRIPT_NAME'

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    More generally, any information you need similar to that (at least that is available in PHP) should be somewhere in one of these variables:
    http://www.php.net/manual/en/reserved.variables.php
    Look at $_SERVER.

    (post, get, cookie, session, etc. are useful too, but those are for other purposes than general information about the environment.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by techietim View Post
    Will this variable be good for you?
    PHP Code:
    $_SERVER['SCRIPT_NAME'
    'SCRIPT_NAME' what is it ? to get current url , what must be ?

  8. #8
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    There is a list here: http://uk2.php.net/reserved.variables.server

    $_SERVER['SCRIPT_NAME'] = Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

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
  •