Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Function -- http_build_query
3
--SKIPIF--
4
<?php if (function_exists('http_build_query')) { echo 'skip'; } ?>
5
--INI--
6
arg_separator.output=QQQ
7
--FILE--
8
<?php
9
require_once 'PHP/Compat.php';
10
PHP_Compat::loadFunction('http_build_query');
11
 
12
// Simple
13
$data = array('foo'=>'bar',
14
             'baz'=>'boom',
15
             'cow'=>'milk',
16
             'php'=>'hypertext processor');
17
 
18
echo http_build_query($data), "\n";
19
 
20
 
21
// With an object
22
class myClass {
23
    var $foo;
24
    var $baz;
25
 
26
    function myClass()
27
    {
28
        $this->foo = 'bar';
29
        $this->baz = 'boom';
30
    }
31
}
32
 
33
$data = new myClass();
34
echo http_build_query($data), "\n";
35
 
36
 
37
// With numerically indexed elements
38
$data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor');
39
echo http_build_query($data), "\n";
40
echo http_build_query($data, 'myvar_'), "\n";
41
 
42
 
43
// With a complex array
44
$data = array('user' => array(
45
                    'name' => 'Bob Smith',
46
                    'age' => 47,
47
                    'sex' => 'M',
48
                    'dob' => '5/12/1956'),
49
             'pastimes' => array(
50
                    'golf',
51
                    'opera',
52
                    'poker',
53
                    'rap'),
54
             'children' => array(
55
                    'bobby' => array(
56
                        'age' => 12,
57
                        'sex' => 'M'),
58
                     'sally' => array(
59
                        'age' => 8,
60
                        'sex'=>'F')),
61
             'CEO');
62
 
63
echo http_build_query($data, 'flags_');
64
?>
65
--EXPECT--
66
foo=barQQQbaz=boomQQQcow=milkQQQphp=hypertext+processor
67
foo=barQQQbaz=boom
68
0=fooQQQ1=barQQQ2=bazQQQ3=boomQQQcow=milkQQQphp=hypertext+processor
69
myvar_0=fooQQQmyvar_1=barQQQmyvar_2=bazQQQmyvar_3=boomQQQcow=milkQQQphp=hypertext+processor
70
user[name]=Bob+SmithQQQuser[age]=47QQQuser[sex]=MQQQuser[dob]=5%2F12%2F1956QQQpastimes[0]=golfQQQpastimes[1]=operaQQQpastimes[2]=pokerQQQpastimes[3]=rapQQQchildren[bobby][age]=12QQQchildren[bobby][sex]=MQQQchildren[sally][age]=8QQQchildren[sally][sex]=FQQQflags_0=CEO