+/* {{{ Sara Golemons http_build_query() */
+#ifndef ZEND_ENGINE_2
+
+/* {{{ proto string http_build_query(mixed formdata [, string prefix])
+ Generates a form-encoded query string from an associative array or object. */
+PHP_FUNCTION(http_build_query)
+{
+ zval *formdata;
+ char *prefix = NULL;
+ int prefix_len = 0;
+ smart_str formstr = {0};
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", &formdata, &prefix, &prefix_len) != SUCCESS) {
+ RETURN_FALSE;
+ }
+
+ if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given.");
+ RETURN_FALSE;
+ }
+
+ if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL) TSRMLS_CC) == FAILURE) {
+ if (formstr.c) {
+ efree(formstr.c);
+ }
+ RETURN_FALSE;
+ }
+
+ if (!formstr.c) {
+ RETURN_NULL();
+ }
+
+ smart_str_0(&formstr);
+
+ RETURN_STRINGL(formstr.c, formstr.len, 0);
+}
+/* }}} */
+#endif /* !ZEND_ENGINE_2 */
+/* }}} */