Use JSON as a data-interchange format. In the PHP script, store the variables in an object or array and output the result of json_encode. For example:
$foo='bar';
$funcs = array('cos', 'sec', 'tan', 'sin')
echo json_encode(compact('foo', 'bam'));
To reduce network traffic, make use of the...