What are the best practices for exchanging data between PHP and Python scripts?

When exchanging data between PHP and Python scripts, a common approach is to use JSON as an intermediary format. PHP can encode data into JSON using the `json_encode` function, and Python can decode JSON using the `json.loads` function. This allows for seamless communication between the two languages without the need for complex data parsing.

```php
// PHP script sending data to Python
$data = array('name' => 'John', 'age' => 30);
$json_data = json_encode($data);
exec("python script.py '$json_data'", $output);
```

In this example, the PHP script encodes an array into JSON and passes it as a command line argument to a Python script. The Python script can then decode the JSON data and process it accordingly.