From 5fd3b4b3bf66e26e503633369dc282156d7d8747 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Fri, 12 Aug 2016 01:39:54 -0700 Subject: [PATCH 1/2] Add additional more examples link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e75d712..8f32d8d 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,8 @@ $multi_curl->addGet('https://www.bing.com/search', array( $multi_curl->start(); // Blocks until all items in the queue have been processed. ``` +More examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples). + ### Available Methods ```php Curl::__construct($base_url = null) From 849137a95ebdba61f211bcf33d4833369f9596ec Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Fri, 12 Aug 2016 02:01:23 -0700 Subject: [PATCH 2/2] Use explicit argument separator when building url --- src/Curl/Curl.php | 2 +- tests/PHPCurlClass/PHPCurlClassTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index c4324cc..3b316c8 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -1094,7 +1094,7 @@ class Curl */ private function buildURL($url, $data = array()) { - return $url . (empty($data) ? '' : '?' . http_build_query($data)); + return $url . (empty($data) ? '' : '?' . http_build_query($data, '', '&')); } /** diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 309518c..8fe25ba 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -2807,4 +2807,29 @@ class CurlTest extends PHPUnit_Framework_TestCase $this->assertFalse(isset($options[CURLOPT_COOKIE])); } + + public function testBuildUrlArgSeparator() + { + $base_url = 'https://www.example.com/path'; + $data = array( + 'arg' => 'value', + 'another' => 'one', + ); + $expected_url = $base_url . '?arg=value&another=one'; + + foreach (array(false, '&', '&') as $arg_separator) { + if ($arg_separator) { + ini_set('arg_separator.output', $arg_separator); + } + + $curl = new Curl(); + + $reflector = new ReflectionObject($curl); + $method = $reflector->getMethod('buildURL'); + $method->setAccessible(true); + + $actual_url = $method->invoke($curl, $base_url, $data); + $this->assertEquals($expected_url, $actual_url); + } + } }