downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

HttpQueryString::singleton> <HttpQueryString::mod
[edit] Last updated: Fri, 14 Jun 2013

view this page in

HttpQueryString::set

(PECL pecl_http >= 0.22.0)

HttpQueryString::setDéfinit les paramètres de la requête

Description

public string HttpQueryString::set ( mixed $params )

Définit les paramètres de la requête. Les valeurs NULL effaceront les variables.

Liste de paramètres

params

paramètres à ajouter

Valeurs de retour

Retourne la requête courante.



add a note add a note User Contributed Notes HttpQueryString::set - [2 notes]
up
0
michal dot kocarek at brainbox dot cz
4 years ago
Function accepts string or associative array in the params argument.

<?php
   $query
= new HttpQueryString(false); // query is empty

  
$query->set(array('city' => 'Prague', 'age' => 34)); // query is "city=Prague&age=34"
  
$query->set('age=20&gender=male'); // query is "city=Prague&age=20&gender=male"
?>

Also please note that variable can be unset *only* by passing NULL value in an associative array.

<?php
$query
->set('city='); // query is "city=&age=20&gender=male"
  
$query->set(array('city' => null)); // and now "age=20&gender=male" ?>
up
0
jerome at rainstormconsulting dot com
5 years ago
In case anybody reads this and wonders what the params should be, it takes a key=>value array, not sure why it says mixed, or if there's other types you can give it.

<?php
$http
= new HttpQueryString();
$http->set(array('page' => 1, 'sort' => 'asc'));
?>

Should produce a query string page?page=1&sort=asc

 
show source | credits | stats | sitemap | contact | advertising | mirror sites