SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Location
    Brussels Belgium Europe
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET default value

    Hello everyone

    I would like to know if $_GET has a sort of a default value?

    What I mean is this: I want to make my url as short as possible, something like

    www.domain.com/?1

    is this possible?

    or it must be www.domain.com/?v=1

    thanks!
    xxx.linguistmail.com
    Learn A Foreign Language
    Sentences Vocabulary Grammar Pronunciation

    Apprendre l'anglais

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Test it
    PHP Code:
    <?php var_dump$_GET );
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Member
    Join Date
    Jun 2009
    Location
    Brussels Belgium Europe
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks logic_earth

    is there an easy way not to display this:
    array(1) { [123]=> string(0) "" }

    I tried $myvar= var_dump ($_GET) but it still displays it.

    I went on php.net and checked var_dump examples. In one of them, they suggest to use var_export($_GET, true) do you think it's ok?
    xxx.linguistmail.com
    Learn A Foreign Language
    Sentences Vocabulary Grammar Pronunciation

    Apprendre l'anglais

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You could use the PATH_INFO element in $_SERVER, given the URL:-
    Code:
    http://www.example.org/index.php/banana
    You could grab 'banana' like so...
    PHP Code:
    <?php
    $var 
    trim($_SERVER['PATH_INFO'], '/');
    ?>
    With a little dash of Apache's mod_rewrite module thrown in, you could quite easily remove index.php from the URL.

    Alternatively, you could still use the query string.
    Code:
    http://www.example.org/?banana
    You could grab 'banana' like so...
    PHP Code:
    <?php
    $var 
    $_SERVER['QUERY_STRING'];
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •