Variable in Variable zetten
Weet iemand hoe je dit op een juiste manier kan doen?
Ja, je dient je variablen ten alle tijden buiten de quotes te halen:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$location = "/home/xbmc/Music";
$data = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "' . $location . '" }, "id": 1}';
echo $data;
?>
$location = "/home/xbmc/Music";
$data = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : "' . $location . '" }, "id": 1}';
echo $data;
?>
Gewijzigd op 29/09/2010 19:19:48 door SilverWolf NL
Je bedoelt dit:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$data = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : \"' .
$location .
' \" }, "id": 1}';
?>
$data = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params" : { "directory" : \"' .
$location .
' \" }, "id": 1}';
?>
Gewijzigd op 29/09/2010 19:13:04 door Martijn B
Ja, maar waarom die nutteloze enters? het maakt het geheel niet beter leesbaar ofzo. Ook kan je de slashes weghalen, omdat er enkele quotes gebruikt worden voor de variable.
Volgens mij moet je gewoon json_encode gebruiken.




