コード例 #1
0
ファイル: QueryParserTest.php プロジェクト: puzzlehttp/puzzle
 public function testCanControlDecodingType()
 {
     $qp = new puzzle_QueryParser();
     $q = new puzzle_Query();
     $qp->parseInto($q, 'var=foo+bar', puzzle_Query::RFC3986);
     $this->assertEquals('foo+bar', $q->get('var'));
     $qp->parseInto($q, 'var=foo+bar', puzzle_Query::RFC1738);
     $this->assertEquals('foo bar', $q->get('var'));
 }
コード例 #2
0
ファイル: Query.php プロジェクト: puzzlehttp/puzzle
 /**
  * Parse a query string into a puzzle_Query object
  *
  * $urlEncoding is used to control how the query string is parsed and how
  * it is ultimately serialized. The value can be set to one of the
  * following:
  *
  * - true: (default) Parse query strings using RFC 3986 while still
  *   converting "+" to " ".
  * - false: Disables URL decoding of the input string and URL encoding when
  *   the query string is serialized.
  * - 'RFC3986': Use RFC 3986 URL encoding/decoding
  * - 'RFC1738': Use RFC 1738 URL encoding/decoding
  *
  * @param string      $query       Query string to parse
  * @param bool|string $urlEncoding Controls how the input string is decoded
  *                                 and encoded.
  * @return self
  */
 public static function fromString($query, $urlEncoding = true)
 {
     static $qp;
     if (!$qp) {
         $qp = new puzzle_QueryParser();
     }
     $q = new self();
     if ($urlEncoding !== true) {
         $q->setEncodingType($urlEncoding);
     }
     $qp->parseInto($q, $query, $urlEncoding);
     return $q;
 }