PHP | http_build_query() Function Last Updated : 09 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The http_build_query() function is an inbuilt function in PHP which is used to generate URL-encoded query string from the associative (or indexed) array. Syntax: string http_build_query( $query_data, $numeric_prefix, $arg_separator, $enc_type = PHP_QUERY_RFC1738 ) Parameters: This function accepts four parameters as mentioned above and described below: $query_data: This parameter holds the array or object containing properties which are given below: It may be a single dimensional array or multi-dimensional array. If $query_data is an object then only public property will be incorporated into the result . $numeric_prefix: This parameter is used if numeric indices are used in the base array, it will be prepended to the numeric index for elements in the base array only. $arg_separator: It is used to separate arguments but may be overridden by specifying this parameter. $enc_type: Its default value is PHP_QUERY_RFC1738. Return Values: It returns a URL-encoded string. Below programs illustrate the http_build_query() function in PHP: Program 1: php <?php $info = array( 'sudo' => 'placement', 'CPP' => 'course', 'FORK' => 'C', ); echo http_build_query($info) . "#"; echo http_build_query($info, '', '&'); ?> Output: sudo=placement&CPP=course&FORK=C#sudo=placement&CPP=course&FORK=C Program 2: php <?php $info = array('geeks', 'gfg' => 'sudo', 'placement' => 'hypertext processor'); echo http_build_query($info) . "$"; echo http_build_query($info, 'myvar_'); ?> Output: 0=geeks&gfg=sudo&placement=hypertext+processor$myvar_0=geeks&gfg=sudo&placement=hypertext+processor Reference: http://docs.php.net/manual/da/function.http-build-query.php Comment More infoAdvertise with us Next Article PHP | filter_list() Function C Code_Mech Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | parse_url() Function The parse_url() function is an inbuilt function in PHP which is used to return the components of a URL by parsing it. It parses an URL and return an associative array which contains its various components. Syntax: parse_url( $url, $component = -1 ) Parameters: This function accepts two parameters as 2 min read PHP | geoip_db_avail() Function The geoip_db_avail() function is an inbuilt function in PHP which is used to check whether a GeoIP database is available or not. The function does not consider the proper existence of a file instead it checks whether it is readable or not. Syntax: bool geoip_db_avail( $database ) Parameters: This fu 2 min read PHP | filter_list() Function The filter_list() function is an inbuilt function in PHP which is used to returns the list of all supported filters. Syntax: array filter_list( void ) Parameters: This function does not accepts any parameters. Return Values: It returns an array containing all names of supported filters. If it return 2 min read PHP | filter_input() Function The filter_input() is an inbuilt function in PHP which is used to get the specific external variable by name and filter it. This function is used to validate variables from insecure sources, such as user input from form. This function is very much useful to prevent some potential security threat lik 2 min read PHP | Imagick queryFormats() Function The Imagick::queryFormats() function is an inbuilt function in PHP which is used to get the formats supported by Imagick. Syntax: array Imagick::queryFormats( string $pattern = "*" ) Parameters: This function accepts a single parameter $pattern which holds the pattern to be matched with formats. Ret 5 min read PHP | ob_start() Function Let's take a quick recap. PHP is an interpreted language thus each statement is executed one after another, therefore PHP tends to send HTML to browsers in chunks thus reducing performance. Using output buffering the generated HTML gets stored in a buffer or a string variable and is sent to the buff 2 min read Like