I call another script with curl
, This script returns (echo()
) a value.
The return value could be anything, array, string, etc.
I can do the transfer with json_encode()
and json_decode()
, But is there any other better way (Without use JSON or $_SESSION['varName']
)?
You may use PHP's own serialize function. It's native, can encode simple objects, and is less ambiguous than JSON.
Sample code:
// page.php
echo serialize($data);
And:
// receiver.php
$data = file_get_contents('http://example.com/page.php');
if ($data) $data = unserialize($data);