Michael Schilli > PHP-HTTPBuildQuery-0.03 > PHP::HTTPBuildQuery

Download:
PHP-HTTPBuildQuery-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.03   Source  

NAME ^

PHP::HTTPBuildQuery - Data structures become form-encoded query strings

SYNOPSIS ^

    use PHP::HTTPBuildQuery qw(http_build_query);

    my $query = http_build_query( { foo => { 
                                      bar   => "baz", 
                                      quick => { "quack" => "schmack" },
                                    },
                                  },
                                );

    # Query: "foo%5Bbar%5D=baz&foo%5Bquick%5D%5Bquack%5D=schmack"

    # URL decoded: "foo[bar]=baz", "foo[quick][quack]=schmack"

DESCRIPTION ^

PHP::HTTPBuildQuery implements PHP's http_build_query function in Perl. It is used to form-encode Perl data structures in URLs, so that PHP can read them on the receiving end.

http_build_query accepts one mandatory and two optional parameters:

     http_build_query( $data, $prefix, $separator );

where

EXAMPLES ^

Array

    $query = http_build_query( ['foo', 'bar'] );

    # Query: "name_0=foo&name_1=bar"

Hash with Array

    $query = http_build_query( { foo => [ 'bar', 'baz' ] } );

    # Query: "foo[0]=bar&foo[1]=baz" (not escaped for readability)

GOTCHAS ^

CHANGES ^

    0.03  2008/10/14
        (ms) Added copyright notice

    0.02  2008/10/03
        (ms) Changed API to be more PHP-like after consulting with 
             Sara Golemon.
        (ms) Added arrays
    
    0.01  2008/10/03
        (ms) Where it all began.

THANKS ^

Thanks to the following Yahoos who provided advice, ideas and code: Sara Golemon, Rasmus Lerdorf, Evan Miller.

COPYRIGHT & LICENSE ^

COPYRIGHT & LICENSE

Copyright (c) 2008 Yahoo! Inc. All rights reserved. The copyrights to the contents of this file are licensed under the Perl Artistic License (ver. 15 Aug 1997)

AUTHOR ^

2008, Mike Schilli <cpan@perlmeister.com>