2016-07-26 2 views
0

私はLaravel 5.2を使用しています。私はjsonファイルを受け取るためのWebリクエストを作成するところのクラスを作成しました。変更と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; 

そして、URLの安全エンコードする:

$urlEncodedRequest = urlencode($request); 
関連する問題