2016-07-26 47 views
0

我使用Laravel 5.2和我刚创建简单的类,我创建Web请求接收JSON文件。更改&到&在php类

因此类的部分看起来像:

public function request(){ 
    $request = 'https://example.com/someotherthings/var='.$value1.'&var2='.$value2'; 
} 

对此我得到:

https://example.com/someotherthings/var=valueOfValue1&var2=valueOfValue2 

的问题是,要求是错误的,我也没有得到回报响应。

+0

您是否尝试过'urlencode'?这里你有文档:http://php.net/manual/es/function.urlencode.php – Mumpo

回答

0

删除最后一个引号:

$request = 'https://example.com/someotherthings/var='.$value1.'&var2='.$value2'; 

变为:

$request = 'https://example.com/someotherthings/var='.$value1.'&var2='.$value2; 

然后是安全编码的网址:

$urlEncodedRequest = urlencode($request);