javascript - I need to insert a parameter in a function with Cakephp
I need to insert the parameter $reg into the string but I can't do it
public function param($apikey, $plant_id, $reg){
$http = new Client();
$response = $http->get('https',[
'apikey'=> $apikey,
'plant_id'=> $plant_id,
'dev_cmd'=>'[{"mod":5,"reg":$reg}]']);
it is seen as a term of the string while it is a declared variable
Answer
Solution:
It is suggested to use POST instead of GET while posting complicated string / data. If it is must to use GET, then use the code below (copied from CakePHP Doc)
$http = new Client();
$response = $http->get(
'http://example.com/tasks',
['q' => 'test', '_content' => json_encode($data)],
['type' => 'json']
);
Source