Can PHP pass a long string to an exec-ed process via STDIN or commandline argument?
<p>I want PHP to send a 10000-character JSON array to a Java program and get a JSON array in return.</p>

<p>There is the exec() method for calling subprocesses, but I dont know how to reliably pass a long string. I see two methods:</p>

<p><strong>Method 1:</strong> Pass the entire string in the commandline. I am worried how to escape a JSON string for the commandline and if it is too much for a Linux commandline to handle. ROFLMAO anyone?</p>

<p><strong>Method 2:</strong> Make the java program wait for a <code>\n</code>-terminated string from STDIN. PHP can send the string to the STDIN of that Java program.</p>

<p>What is a good method to pass a long string to a Java subprocess?</p>
