File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings / http_build_query_variation1.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:10 2013 UTC (11 years ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

--TEST--
Test http_build_query() function: usage variations - first arguments as object 
--CREDITS--
Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com>
--FILE--
<?php
/* Prototype  : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )
 * Description: Generates a URL-encoded query string from the associative (or indexed) array provided. 
 * Source code: ext/standard/http.c
*/

class UrlBuilder
{
  public $name = 'homepage';
  public $page = 1;
  protected $sort = 'desc,name';
  private $access = 'admin';
}

$obj = new stdClass;
$obj->name = 'homepage';
$obj->page = 1;
$obj->sort = 'desc,name';

echo http_build_query($obj) . PHP_EOL;
echo http_build_query(new UrlBuilder());
?>
--EXPECTF--
name=homepage&page=1&sort=desc%2Cname
name=homepage&page=1

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>